uriparser / uriparser

:hocho: Strictly RFC 3986 compliant URI parsing and handling library written in C89; moved from SourceForge to GitHub

Home Page:https://uriparser.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Escape URI

aphasix opened this issue · comments

I need to parse an url before encoding each part separately, since apparently encoding the whole url gives wrong output (http:// is escaped for example).
(note I have a Linux based implementation)

So I first execute uriParseSingleUriA, then execute uriEscapeExA on each URI part (except scheme and host that cannot (should not?) contain escaped characters)
If my input url contains a path with spaces (file name with spaces for example) uriParseSingleUriA replies with a syntax errors, pointing to the first space encountered.

How can I pct-encode that URL if the characters that need to be escaped creates an issue with uriParseSingleUriA?

In the other hand, if I provide a pct-encoded URL to uriParseSingleUriA, the parsing is OK but escaping the URI parts using uriEscapeExA, it encodes the already encoded parts while I expected the lib would avoid the double escaping.
example:
http://localhost:8080/resources/file%20with%20space%201kb.bin
becomes
http://localhost:8080/resources/file%2520with%2520space%25201kb.bin

I probably lack some advice, please help, thanks!

Hi @aphasix when you start with a URI and want to use the result after parsing I would expect you un(!)escape things rather than escape. Could you help me understand the big picture and your scenario better? Currently, I have no understanding of what you're trying to do and why you would want it. Thanks!

Closing due to lack of a reply…