Telegraph icon indicating copy to clipboard operation
Telegraph copied to clipboard

URL with square brackets

Open kiwifruituk opened this issue 3 years ago • 2 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.

kiwifruituk avatar Dec 03 '21 12:12 kiwifruituk

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.

masture avatar Feb 07 '22 14:02 masture

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

yvbeek avatar Aug 13 '22 04:08 yvbeek