Commit 0d9dc044 authored by Alberto Donizetti's avatar Alberto Donizetti Committed by Brad Fitzpatrick

net/url: clarify QueryUnescape and PathUnescape doc

In the doc for QueryUnescape and PathUnescape, clarify that by 0xAB we
means a substring with any two valid hexadecimal digits.

Fixes #18642

Change-Id: Ib65b130995ae5fcf07e25ee0fcc41fad520c5662
Reviewed-on: https://go-review.googlesource.com/77050Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent fa1f52c5
...@@ -163,18 +163,23 @@ func shouldEscape(c byte, mode encoding) bool { ...@@ -163,18 +163,23 @@ func shouldEscape(c byte, mode encoding) bool {
return true return true
} }
// QueryUnescape does the inverse transformation of QueryEscape, converting // QueryUnescape does the inverse transformation of QueryEscape,
// %AB into the byte 0xAB and '+' into ' ' (space). It returns an error if // converting 3-byte encoded substrings of the form "%AB" into the
// any % is not followed by two hexadecimal digits. // hex-decoded byte 0xAB. It also converts '+' into ' ' (space).
// It returns an error if any % is not followed by two hexadecimal
// digits.
func QueryUnescape(s string) (string, error) { func QueryUnescape(s string) (string, error) {
return unescape(s, encodeQueryComponent) return unescape(s, encodeQueryComponent)
} }
// PathUnescape does the inverse transformation of PathEscape, converting // PathUnescape does the inverse transformation of PathEscape,
// %AB into the byte 0xAB. It returns an error if any % is not followed by // converting 3-byte encoded substrings of the form "%AB" into the
// two hexadecimal digits. // hex-decoded byte 0xAB. It also converts '+' into ' ' (space).
// It returns an error if any % is not followed by two hexadecimal
// digits.
// //
// PathUnescape is identical to QueryUnescape except that it does not unescape '+' to ' ' (space). // PathUnescape is identical to QueryUnescape except that it does not
// unescape '+' to ' ' (space).
func PathUnescape(s string) (string, error) { func PathUnescape(s string) (string, error) {
return unescape(s, encodePathSegment) return unescape(s, encodePathSegment)
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment