URL with square brackets
kiwifruituk opened this issue · comments
We've been supplied files from a third party supplier with files that contain square brackets in the name, i.e [root.m].js
This is causing the following error:
Invalid data, parser failed with code 2
As the parsing fails the request.uri
returns /
and subsequently the resource fails to load.
The valid characters in an URI are:
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
The other ASCII characters are categorised as following:
reserved = gen-delims / sub-delims
gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"
sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
/ "*" / "+" / "," / ";" / "="
This is taken from RFC 3986 (Uniform Resource Identifier (URI): Generic Syntax)
Hence square brackets cannot be used as-is. However these can be used with Percent Encoding.
I don't know whether Telegraph
supports Percent Encoding or not. Please try.
The URI
component is using Apple's URLComponents
object to break the string into the relevant parts. I think that this is throwing an error when you use some of these characters.
The C HTTP parser that we're using has some functionality for url parsing, we might be able to use that. Would probably make url parsing faster too