dart-lang / http_parser

A platform-independent Dart package for parsing and serializing HTTP formats.
https://pub.dev/packages/http_parser
BSD 3-Clause "New" or "Revised" License
38 stars 28 forks source link

Exception when content-type contains colon #76

Open gualse opened 1 year ago

gualse commented 1 year ago

Testing versions:

4.0.2 and c14fbf

Steps to Reproduce:

  1. Find any instance of diaspora*, Mobilizon, Pleroma, Akkoma, Funkwhale or WriteFreely (you can use Fediverse Observer)
  2. Open https://<instance>/.well-known/nodeinfo
  3. Take any link with href key and try to load it via http package

Expected Result:

Just a response

Actual Result:

E/flutter ( 4133): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Error on line 1, column 31: Invalid media type: expected no more input.
E/flutter ( 4133):   ╷
E/flutter ( 4133): 1 │ application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8
E/flutter ( 4133):   │                               ^
E/flutter ( 4133):   ╵
E/flutter ( 4133): #0      wrapFormatException (package:http_parser/src/utils.dart:15:5)
E/flutter ( 4133): #1      new MediaType.parse (package:http_parser/src/media_type.dart:46:7)
E/flutter ( 4133): #2      _contentTypeForHeaders (package:http/src/response.dart:79:45)
E/flutter ( 4133): #3      _encodingForHeaders (package:http/src/response.dart:72:24)
E/flutter ( 4133): #4      Response.body (package:http/src/response.dart:28:22)