Buggy code:
public class UrlValidator extends AbstractValidator < String > { private static final long serialVersionUID = 1L ; public static final int ALLOW_ALL_SCHEMES = 1 << 0 ; public static final int ALLOW_2_SLASHES = 1 << 1 ; public static final int NO_FRAGMENTS = 1 << 2 ; private static final String ALPHA_CHARS = "a-zA-Z" ; private static final String ALPHA_NUMERIC_CHARS = ( UrlValidator . ALPHA_CHARS ) + "\\d" ; private static final String SPECIAL_CHARS = ";//@&=,.?:+$" ; private static final String VALID_CHARS = ( "[^\\s" + ( UrlValidator . SPECIAL_CHARS ) ) + "]" ; private static final String SCHEME_CHARS = UrlValidator . ALPHA_CHARS ; private static final String AUTHORITY_CHARS = ( UrlValidator . ALPHA_NUMERIC_CHARS ) + "\\-\\." ; private static final String ATOM = ( UrlValidator . VALID_CHARS ) + '+' ; private static final String URL_PATTERN = "^(([^://?#]+):)?(////([^//?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?" ; private static final int PARSE_URL_SCHEME = 2 ; private static final int PARSE_URL_AUTHORITY = 4 ; private static final int PARSE_URL_PATH = 5 ; private static final int PARSE_URL_QUERY = 7 ; private static final int PARSE_URL_FRAGMENT = 9 ; private static final String SCHEME_PATTERN = ( "^[" + ( UrlValidator . SCHEME_CHARS ) ) + "].*$" ; private static final String AUTHORITY_PATTERN = ( "^(.+(:.*)?@)?([" + ( UrlValidator . AUTHORITY_CHARS ) ) + "]*)(:\\d*)?(.*)?" ; private static final int PARSE_AUTHORITY_HOST_IP = 3 ; private static final int PARSE_AUTHORITY_PORT = 4 ; private static final int PARSE_AUTHORITY_EXTRA = 5 ; private static final String PATH_PATTERN = "^(//[-\\w:@&?=+,.!//~*\'%$_;]*)?$" ; private static final String QUERY_PATTERN = "^(.*)$" ; private static final String LEGAL_ASCII_PATTERN = "^[\\x00-\\x7F]+$" ; private static final String IP_V4_DOMAIN_PATTERN = "^(\\d{1,3})[.](\\d{1,3})[.](\\d{1,3})[.](\\d{1,3})$" ; private static final String DOMAIN_PATTERN = ( ( ( "^" + ( UrlValidator . ATOM ) ) + "(\\." ) + ( UrlValidator . ATOM ) ) + ")*$" ; private static final String PORT_PATTERN = "^:(\\d{1,5})$" ; private static final String ATOM_PATTERN = ( "(" + ( UrlValidator . ATOM ) ) + ")" ; private static final String ALPHA_PATTERN = ( "^[" + ( UrlValidator . ALPHA_CHARS ) ) + "]" ; private long options = 0 ; private final Set < String > allowedSchemes = new HashSet < String > ( ) ; protected String [ ] defaultSchemes = new String [ ] { "http" , "https" , "ftp" } ; public UrlValidator ( ) { } public UrlValidator ( String [ ] schemes ) { } public UrlValidator ( int options ) { } public UrlValidator ( String [ ] schemes , int options ) { } @ Override protected void onValidate ( IValidatable < String > validatable ) { } public final boolean isValid ( String value ) { } protected boolean isValidScheme ( String scheme ) { } protected boolean isValidAuthority ( String authority ) { } protected boolean isValidPath ( String path ) { if ( path == null ) { return false ; } Matcher pathMatcher = Pattern . compile ( UrlValidator . PATH_PATTERN ) . matcher ( path ) ; if ( ! ( pathMatcher . matches ( ) ) ) { return false ; } int slash2Count = countToken ( "////" , path ) ; if ( ( isOff ( UrlValidator . ALLOW_2_SLASHES ) ) && ( slash2Count > 0 ) ) { return false ; } int slashCount = countToken ( "//" , path ) ; <START_BUG> int dot2Count = countToken ( ".." , path ) ; <END_BUG> if ( dot2Count > 0 ) { if ( ( ( slashCount - slash2Count ) - 1 ) <= dot2Count ) { return false ; } } return true ; } protected boolean isValidQuery ( String query ) { } protected boolean isValidFragment ( String fragment ) { } protected int countToken ( String token , String target ) { } public static boolean isBlankOrNull ( String value ) { } public boolean isOn ( long flag ) { } public boolean isOff ( long flag ) { } }

Fix:
int dot2Count = countToken ( "//.." , path ) ;