guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v4] Add resolve-relative-reference in (web uri), as in RFC 3986 5


From: Nathan
Subject: [PATCH v4] Add resolve-relative-reference in (web uri), as in RFC 3986 5.2.
Date: Thu, 02 Nov 2023 16:00:51 -0400

There is a problem and I fixed it by rewriting a bunch of code myself because I 
need similar code.

remove-dot-segments:
You cannot split-and-decode-uri-path and then encode-and-join-uri-path.
Those are terrible functions that don't work on all URIs.
URI schemes are allowed to specify that certain reserved characters 
(sub-delims) are special.
In that case, a sub-delim that IS escaped is different from a sub-delim that IS 
NOT escaped.

Example input to your remove-dot-segments:
(resolve-relative-reference (string->uri-reference "/") (string->uri-reference 
"excitement://a.com/a!a!%21!"))
Your wrong output:
excitement://a.com/a%21a%21%21%21

One solution would be to only percent-decode dots. Because dot is unreserved, 
that solution doesn't have any URI equivalence issues.
But I still think decoding dots automatically is a bad, unexpected side-effect 
to have.
I rewrote this function so that it:
- works on both escaped and unescaped dots
- doesn't unescape any unnecessary characters

The test suite no longer needs to check for incorrect output either:
> ;; The test suite checks for ';' characters, but Guile escapes
> ;; them in URIs. Same for '='.

----

resolve-relative-reference:
I rewrote this procedure so it is shorter.
I also added #:strict? to toggle "strict parser" as mentioned in the RFC.

- Nathan

Attachment: 0001-Add-resolve-relative-reference-in-web-uri-as-in-RFC-.patch
Description: patch


reply via email to

[Prev in Thread] Current Thread [Next in Thread]