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

Unified Diff: pkg/http/test/multipart_test.dart

Issue 218993016: Make MultipartRequest more closely adhere to browsers' behavior. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 9 months 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/http/lib/src/multipart_request.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/test/multipart_test.dart
diff --git a/pkg/http/test/multipart_test.dart b/pkg/http/test/multipart_test.dart
index 7467d5f0b31f20e1ad29cb46911acb6706f4e7af..f8cb322ea9c18fe38fe426a8c5d98ef50a2170fa 100644
--- a/pkg/http/test/multipart_test.dart
+++ b/pkg/http/test/multipart_test.dart
@@ -93,7 +93,33 @@ void main() {
expect(request, bodyMatches('''
--{{boundary}}
- content-disposition: form-data; name="f%C3%AF%C4%93ld"
+ content-disposition: form-data; name="fïēld"
+
+ value
+ --{{boundary}}--
+ '''));
+ });
+
+ test('with a field name with newlines', () {
+ var request = new http.MultipartRequest('POST', dummyUrl);
+ request.fields['foo\nbar\rbaz\r\nbang'] = 'value';
+
+ expect(request, bodyMatches('''
+ --{{boundary}}
+ content-disposition: form-data; name="foo%0D%0Abar%0D%0Abaz%0D%0Abang"
+
+ value
+ --{{boundary}}--
+ '''));
+ });
+
+ test('with a field name with a quote', () {
+ var request = new http.MultipartRequest('POST', dummyUrl);
+ request.fields['foo"bar'] = 'value';
+
+ expect(request, bodyMatches('''
+ --{{boundary}}
+ content-disposition: form-data; name="foo%22bar"
value
--{{boundary}}--
@@ -122,7 +148,37 @@ void main() {
expect(request, bodyMatches('''
--{{boundary}}
content-type: text/plain; charset=utf-8
- content-disposition: form-data; name="file"; filename="f%C3%AFl%C4%93name.txt"
+ content-disposition: form-data; name="file"; filename="fïlēname.txt"
+
+ contents
+ --{{boundary}}--
+ '''));
+ });
+
+ test('with a filename with newlines', () {
+ var request = new http.MultipartRequest('POST', dummyUrl);
+ request.files.add(new http.MultipartFile.fromString('file', 'contents',
+ filename: 'foo\nbar\rbaz\r\nbang'));
+
+ expect(request, bodyMatches('''
+ --{{boundary}}
+ content-type: text/plain; charset=utf-8
+ content-disposition: form-data; name="file"; filename="foo%0D%0Abar%0D%0Abaz%0D%0Abang"
+
+ contents
+ --{{boundary}}--
+ '''));
+ });
+
+ test('with a filename with a quote', () {
+ var request = new http.MultipartRequest('POST', dummyUrl);
+ request.files.add(new http.MultipartFile.fromString('file', 'contents',
+ filename: 'foo"bar'));
+
+ expect(request, bodyMatches('''
+ --{{boundary}}
+ content-type: text/plain; charset=utf-8
+ content-disposition: form-data; name="file"; filename="foo%22bar"
contents
--{{boundary}}--
« no previous file with comments | « pkg/http/lib/src/multipart_request.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698