[erlang-patches] edoc_lib: padding escaped characters with a leading 0, when their value is one-digit long

Richard Carlsson <>
Thu Aug 18 14:51:37 CEST 2011


On 08/14/2011 05:43 PM, Alfonso De Gregorio wrote:
> When escaping characters less than or equal to 9, the escape_byte/1
> does not pad the result with a leading $0 (e.g., "\x01" is escaped in
> %1 and not in %01). The latter would be the expected representation of
> binary data in a URI according to RFC 3986 (and the specs it updates),
> where the percent encoding mechanism is standardized.
>
> The fix is tiny. Being in doubt about the preferred style to follow
> for OTP, here are two proposals:
>
> [...]
>
> My preference goes to the former.

Thanks for the report, but I preferred neither suggestion. If the code 
should output two characters always, then it is better to rewrite it 
completely. (Also, in your first suggestion, a hex number is 1 char if 
it is =< 15, not =< 9.)

I have included the change in the edoc development repository and will 
push it to OTP later:

https://github.com/richcarl/edoc/commit/1a52f6fcbfe37aaa9a5f72eebfe73c8087f0640e

    /Richard


More information about the erlang-patches mailing list