| Index: pkg/http_server/lib/src/http_multipart_form_data_impl.dart
|
| diff --git a/pkg/http_server/lib/src/http_multipart_form_data_impl.dart b/pkg/http_server/lib/src/http_multipart_form_data_impl.dart
|
| index daebeec40f6322e9d90035657b6022d31b7052b3..ed41d1df82791cf8e73c725d17a13ae85eb3ce3a 100644
|
| --- a/pkg/http_server/lib/src/http_multipart_form_data_impl.dart
|
| +++ b/pkg/http_server/lib/src/http_multipart_form_data_impl.dart
|
| @@ -32,23 +32,12 @@ class _HttpMultipartFormData extends Stream implements HttpMultipartFormData {
|
| contentType.primaryType == 'text' ||
|
| contentType.mimeType == 'application/json') {
|
| _isText = true;
|
| - StringBuffer buffer = new StringBuffer();
|
| Encoding encoding;
|
| - if (contentType != null) {
|
| + if (contentType != null && contentType.charset != null) {
|
| encoding = Encoding.getByName(contentType.charset);
|
| }
|
| if (encoding == null) encoding = defaultEncoding;
|
| - _stream = _stream
|
| - .transform(encoding.decoder)
|
| - .expand((data) {
|
| - buffer.write(data);
|
| - var out = _decodeHttpEntityString(buffer.toString());
|
| - if (out != null) {
|
| - buffer.clear();
|
| - return [out];
|
| - }
|
| - return const [];
|
| - });
|
| + _stream = _stream.transform(encoding.decoder);
|
| }
|
| }
|
|
|
| @@ -102,41 +91,4 @@ class _HttpMultipartFormData extends Stream implements HttpMultipartFormData {
|
| String value(String name) {
|
| return _mimeMultipart.headers[name];
|
| }
|
| -
|
| - // Decode a string with HTTP entities. Returns null if the string ends in the
|
| - // middle of a http entity.
|
| - static String _decodeHttpEntityString(String input) {
|
| - int amp = input.lastIndexOf('&');
|
| - if (amp < 0) return input;
|
| - int end = input.lastIndexOf(';');
|
| - if (end < amp) return null;
|
| -
|
| - var buffer = new StringBuffer();
|
| - int offset = 0;
|
| -
|
| - parse(amp, end) {
|
| - switch (input[amp + 1]) {
|
| - case '#':
|
| - if (input[amp + 2] == 'x') {
|
| - buffer.writeCharCode(
|
| - int.parse(input.substring(amp + 3, end), radix: 16));
|
| - } else {
|
| - buffer.writeCharCode(int.parse(input.substring(amp + 2, end)));
|
| - }
|
| - break;
|
| -
|
| - default:
|
| - throw new HttpException('Unhandled HTTP entity token');
|
| - }
|
| - }
|
| -
|
| - while ((amp = input.indexOf('&', offset)) >= 0) {
|
| - buffer.write(input.substring(offset, amp));
|
| - int end = input.indexOf(';', amp);
|
| - parse(amp, end);
|
| - offset = end + 1;
|
| - }
|
| - buffer.write(input.substring(offset));
|
| - return buffer.toString();
|
| - }
|
| }
|
|
|