[haiku-commits] Re: haiku: hrev47610 - src/kits/network/libnetapi build/jam/repositories/HaikuPorts

  • From: Jérôme Duval <jerome.duval@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 1 Aug 2014 17:04:26 +0200

2014-08-01 9:40 GMT+02:00  <pulkomandy@xxxxxxxxxxxxx>:
> -                       char hexString[] = { chunk[i + 1], chunk[i + 2], 0 };
> -                       result << (char)strtol(hexString, NULL, 16);
> +                       bool isEncoded = false;
> +                       char decoded = 0;
> +
> +                       if (chunk[i] == '%' && i < chunk.Length() - 2)
> +                       {
> +                               char hexString[] = { chunk[i + 1], chunk[i + 
> 2], 0 };
> +                               char* out = NULL;
> +                               decoded = (char)strtol(hexString, &out, 16);
> +                               if (out == hexString + 2) {
> +                                       isEncoded = true;
> +                                       i += 2;
> +                               }
> +                       }

Style issue.
This code wrongly accepts "%-1": I'd recommend using isxdigit() on
chunk[i+1] and chunk[i+2].

Bye,
Jérôme

Other related posts: