Dear Wolfgang,
ns_parseurl is intended to parse a compete URL, including scheme,
authority (host, port),
path, query and fragment
foo://example.com:8042/over/there?name=ferret#nose
\_/ \______________/\_________/ \_________/ \__/
| | | | |
scheme authority path query fragment
The path has to start with a slash, so it tries to parse the scheme,
when the first
characters of the scheme look ok. When the scheme is not properly
terminated,
it complains. In your example, it found the terminating colon.... I
have now
made the parsing more robust, also in the cases where these are not fully
percent-encoded, while keeping the error cases constant.
We see now the following results
% ns_parseurl "/test/index?url=http://www.test.at"
path test tail index query url=http://www.test.at
% ns_parseurl "index?url=http://www.test.com"
tail index query url=http://www.test.com
% ns_parseurl "/index?url=http://www.test.com"
path {} tail index query url=http://www.test.com
% ns_parseurl "index?url=https//www.test.com"
tail index query url=https//www.test.com
Altogether, we have now 81 tests for the URL parsing...
The changes a committed on Bitbucket.
Let me know, in case you found other questionable cases.
all the best
-gn
On 14.01.22 08:34, Wolfgang Winkler via naviserver-devel wrote:
Hello all!
We encountered a small problem with ns_parseurl:
When parsing
ns_parseurl "/test/index?url=http://www.test.at"
everything works fine.
With
ns_parseurl "index?url=http://www.test.com"
We get "Could not parse URL "index?url=https://www.test.com": invalid
scheme"
* ns_parseurl "/index?url=http://www.test.com"
* ns_parseurl "index?url=https//www.test.com" (notice the missing ":")
work as well.
The "url" Parameter is encoded with ns_urlencode. When encoding with JS:
encodeURIComponent("http://www.test.com");
we get
'http%3A%2F%2Fwww.test.com'
Using this value:
ns_parseurl "index?url=http%3A%2F%2Fwww.test.com"
works. ns_urldecode decodes the value correctly.
Regards,
Wolfgang
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel
--
Univ.Prof. Dr. Gustaf Neumann
Head of the Institute of Information Systems and New Media
of Vienna University of Economics and Business
Program Director of MSc "Information Systems"
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel