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

Alfonso De Gregorio <>
Thu Aug 18 15:22:17 CEST 2011


On Thu, Aug 18, 2011 at 2:51 PM, Richard Carlsson
<> wrote:
> 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.
>
> (Also, in your first suggestion, a hex number is 1 char if it is
> =< 15, not =< 9.)

D'oh! I'd really would like to know where I had my head when I wrote
such an inattentive guard clause...


> 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


Thanks Richard. The escaping code works now more consistently and
looks also neater.

Cheers,


-- alfonso     blogs at http://Plaintext.crypto.lo.gy   tweets @secYOUre


More information about the erlang-patches mailing list