Skip to content

Commit 11fc325

Browse files
Richmairaw
andcommitted
Space characters are encoded as '+' (#3124)
* Space characters are encoded as '+' Existing description implies that the specified character classes are the only exceptions to hexadecimal encoding. I'm trying to match Javascript 'encodeURIComponent' behavior, and expected WebUtility.UrlEncode to provide this. However, as spaces are a further exception, this method produces results that are functionally identical to that produced by HttpUtility.UrlEncode. Might also be useful to mention Uri.EscapeDataString and AntiXss.UrlEncode as well here, as these are now preferred options when looking to encode URIs in a transparent, reversible manner. * Update xml/System.Net/WebUtility.xml As requested, removed reference to HttpUtility. Thanks @davidsh and @mairaw Co-Authored-By: Maira Wenzel <[email protected]>
1 parent 1eb90f6 commit 11fc325

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

xml/System.Net/WebUtility.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,8 @@
424424
425425
- `(` and `)` (opening and closing parentheses)
426426
427+
Each ' ' (space) character is converted to a `+` (plus) character.
428+
427429
For example, when embedded in a block of text to be transmitted in a URL, the characters `<` and `>` are encoded as `%3c` and `%3e`.
428430
429431
The <xref:System.Net.WebUtility.UrlDecode%2A> method reverses the encoding.

0 commit comments

Comments
 (0)