Skip to content

Colon in path throws ArgumentError #128

Open
@jonasfj

Description

@jonasfj

Throws in:

shelf/lib/src/request.dart

Lines 178 to 184 in fbc691a

if (this.handlerPath + this.url.path != this.requestedUri.path) {
throw ArgumentError.value(
requestedUri,
'requestedUri',
'handlerPath "$handlerPath" and url "$url" must '
'combine to equal requestedUri path "${requestedUri.path}".');
}

Because _computeUrl returns a URI with a relative path in:

shelf/lib/src/request.dart

Lines 318 to 320 in fbc691a

// Skip the initial "/".
var path = requestedUri.path.substring(1);
return Uri(path: path, query: requestedUri.query);

From https://tools.ietf.org/html/rfc3986#section-3.3

In addition, a URI reference (Section 4.1) may be a relative-path reference, in which case the first path segment cannot contain a colon (":") character.

Hence, we see that Uri(path: 'a:a').path is URL-encoded, because it's a relative URL and not absolute URL unlike requestedUri which is absolute, hence, colon is not encoded in requestedUri.path, and we get an ArgumentError.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions