Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1121)

Unified Diff: sdk/lib/uri/encode_decode.dart

Issue 11659009: Reapply "Fix URI encoding/decoding of + and space"" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated tests Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/oauth2/test/authorization_code_grant_test.dart ('k') | tests/standalone/io/url_encoding_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/uri/encode_decode.dart
diff --git a/sdk/lib/uri/encode_decode.dart b/sdk/lib/uri/encode_decode.dart
index 0e94e1f98a2cf18a0124c317f25293c3b4afd743..e8d483bf67174ac291b66fa39cf17100625f3009 100644
--- a/sdk/lib/uri/encode_decode.dart
+++ b/sdk/lib/uri/encode_decode.dart
@@ -22,7 +22,7 @@ part of dart.uri;
*/
String encodeUri(String uri) {
return _uriEncode(
- "-_.!~*'()#;,/?:@&=+\$0123456789"
+ "-_.!~*'()#;,/?:@&=\$0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", uri);
}
@@ -82,6 +82,8 @@ String _uriEncode(String canonical, String text) {
for (int i = 0; i < text.length; i++) {
if (canonical.indexOf(text[i]) >= 0) {
result.add(text[i]);
+ } else if (text[i] == " ") {
+ result.add("+");
} else {
int ch = text.charCodeAt(i);
if (ch >= 0xD800 && ch < 0xDC00) {
@@ -137,7 +139,11 @@ String _uriDecode(String text) {
for (int i = 0; i < text.length;) {
String ch = text[i];
if (ch != '%') {
- result.add(ch);
+ if (ch == '+') {
+ result.add(" ");
+ } else {
+ result.add(ch);
+ }
i++;
} else {
codepoints.clear();
« no previous file with comments | « pkg/oauth2/test/authorization_code_grant_test.dart ('k') | tests/standalone/io/url_encoding_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698