Skip to content

HttpRequest.queryParameters does not decode parameters including multi-byte characters #2902

@DartBot

Description

@DartBot

This issue was originally filed by [email protected]


I Wrote DumpHttpRequest.dart server code to evaluate the dart:io.HttpRequest interface. Using this server, I found several issues.

What steps will reproduce the problem?

  1. Unzip attached folder.
  2. From Dart editor, File > Open Folder and select this DumpHttpRequest folder.
  3. Run DumpHttpRequest.dart as server.
  4. Access the DumpHttpRequest.html file from your browser such as : file:///C:/ … /DumpHttpRequest/DumpHttpRequest.html
  5. Enter some text to the text areas and click “Submit using POST” or “Submit using GET” button.
  6. This server will return available data from the request. This data is also available on the Dart editor’s console.

What is the expected output? What do you see instead?
1:
Method HttpRequest.queryParameters does not decode parameters including multi-byte characters. When entered “√2 is 1.414” to the lower text area and click “Submit using GET” button, the DumpHttpRequest server returns following list. As shown in the line 006, name is returned correctly but the value (includes √: %E2%88%9A character) is vacant. If you entered “Hello World!”, correct result string value will be returned.

001 request.method : GET
002 request.path : /DumpHttpRequest
003 request.uri : /DumpHttpRequest?submitGet=%E2%88%9A2+is+1.414
004 request.queryString : submitGet=%E2%88%9A2+is+1.414
005 request.queryParameters :
006 submitGet :
007 request.headers.expires : null
008 request.headers.host : localhost
009 request.headers.port : 8080
010 request.headers :
011 accept-encoding: gzip,deflate,sdch
012 accept-charset: Shift_JIS,utf-8;q=0.7,;q=0.3
013 accept-language: ja,en-US;q=0.8,en;q=0.6
014 connection: keep-alive
015 host: localhost:8080
016 accept: text/html,application/xhtml+xml,application/xml;q=0.9,
/*;q=0.8
017 user-agent: Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19
018 *URL decoded request.queryString using urlDecode() : submitGet=√2 is 1.414

2:
Line 018 of above list is a URL decoded request.queryString string. I wrote this function to obtain query parameters including Japanese characters without using HttpRequest. queryParameters. Below line 162 of DumpHttpRequest.dart code is a sample of URL decode / encode functions. We will need such functions with optional arg enc (like java.net.URLEncoder.encode and java.net.URLDecoder.decode). Function urlDecode is used to decode URL encoded POST body data. Default enctype of HTML Form is “application/x-www-form-urlencoded”. Function urlEncode will be used to generate cookie header data.

3:
Chrome says “accept-charset: Shift_JIS,utf-8;q=0.7,*;q=0.3” as shown in the line 013 of the above list. Character set Shift_JIS (Windows-31J) is a commonly used encoding in Japan other than UTF-8. I urge Dart team to include Shift_JIS to the Encoding class in the near future. Furthermore, replacing the line 009 of the DumpHttpRequest.html code with the line 012 will generate query strings consisting of URL encoded Shit_JIS 2 byte codes. Does Dart team have any plan to cope with such encodings?

4:
Current HttpHeaders interface does not have methods to get Map or List of (name, value) pairs and length field is not available. Map implemented HttpHeaders will be more convenient to know what headers are included in the request. Separating each header from HttpRequest.headers.toString() is not a smart way.

What version of the product are you using? On what operating system?
Dart editor: Version 0.1.0.201204250751, Build 6943
Dart SDK version 6943, Dartium version
Windows Vista, 32bits

Please provide any additional information below.


Attachment:
DumpHttpRequest.zip (3.45 KB)

Metadata

Metadata

Assignees

Labels

area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.library-io

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions