Skip to content

scheme:/.//foo/bar is incorrectly normalized to scheme://foo/bar #262

@TimWolla

Description

@TimWolla

Initially reported for the PHP project at php/php-src#19897.

This one is a little complicated, because the normalization itself is working correctly, it's that the stringification after normalization behaves incorrectly.

When patching the uriparse tool as follows:

--- i/tool/uriparse.c
+++ w/tool/uriparse.c
@@ -92,6 +92,8 @@ int main(int argc, char *argv[]) {
                                        (long unsigned int)(state.errorPos - argv[i]));
                        retval = EXIT_FAILURE;
                } else {
+                       uriNormalizeSyntaxA(&uri);
+
                        if (uri.scheme.first) {
                                printf("scheme:       %.*s\n", RANGE(uri.scheme));
                        }

to normalize a URI before printing the individual components, the normalized URI internally looks like:

uri:          scheme:/.//foo/bar
scheme:       scheme
 .. pathSeg:  
 .. pathSeg:  foo
 .. pathSeg:  bar
absolutePath: true

This then is stringified into scheme://foo/bar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions