[erlang-patches] edoc_lib: padding escaped characters with a leading 0, when their value is one-digit long
Alfonso De Gregorio
Sun Aug 14 17:43:02 CEST 2011
I was escaping few URI segments with edoc_lib:escape_uri/1, when I've
noticed what seemingly is an unintended behaviour.
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:
1. [clause] Adding one clause to escape_byte/1 when the value is one digit long:
git fetch git://github.com/secYOUre/otp.git
2. [one-line] With right/3, it is a one-line change (traded for one
git fetch git://github.com/secYOUre/otp.git hotfix-edoc_lib-escape_byte
My preference goes to the former.
-- alfonso blogs at http://Plaintext.crypto.lo.gy tweets @secYOUre
More information about the erlang-patches