jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Gaul <notificati...@github.com>
Subject Re: [jclouds] tighten the isUrlEncoded check (#755)
Date Wed, 27 May 2015 23:40:58 GMT
>  
>     public static boolean isUrlEncoded(String in) {
> -      return URL_ENCODED_PATTERN.matcher(in).matches();
> +      if (!URL_VALID_PATTERN.matcher(in).matches()) {
> +         return false;
> +      }
> +
> +      // ensure that all % are followed by 2 hexadecimal characters
> +      int percentIdx = 0;
> +      while ((percentIdx = in.indexOf('%', percentIdx)) != -1) {
> +         if (percentIdx + 2 >= in.length()) {
> +            return false;
> +         }
> +         if (!isHexadecimal(in.charAt(percentIdx + 1)) ||
> +                 !isHexadecimal(in.charAt(percentIdx + 2))) {
> +            System.err.println("% is followed by non-alphanumeric " + in.substring(percentIdx,
percentIdx + 2));

Remove -- we cannot spam `System.err`.  Optionally introduce a logger instead.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/755/files#r31191727
Mime
View raw message