Re: [naviserver-devel] percent-encoded characters in URL

2021-08-25 Thread Gustaf Neumann

On 25.08.21 11:07, Wolfgang Winkler wrote:
Thank you for your answer. I've missed the corresponding RFC 3986 part 
you quoted.


We have a client who, for some reason, got an error, when the @ sign 
of emails in the query section was not escaped. It has been solved on 
his side, but I was not sure what the more standard compliant version 
was. I've tried it myself with various libraries and clients and none 
hat a problem with the NaviServer version. They might use an outdated 
java library somewhere.


One potential problem might be, if there is a literal comparison of the 
result of JavaScript encodeURIComponent() with the result of 
ns_urlencode, or some sloppy parser Would it be of help for you, 
when we would add one more encoding table (e.g. named "js") to 
ns_urlencode to produce the same result as encodeURIComponent() ?



BTW: I love the nsv dicts and the ns_crypto stuff.


Great, many thanks for the feedback

-g

___
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


Re: [naviserver-devel] percent-encoded characters in URL

2021-08-25 Thread Gustaf Neumann

Dear Wolfgang,

according to RFC 3986, the at-sign should not be encoded, neither in the 
path segments, nor in the query components.

For querycomponents the right parameter for ns_urlencode is

  ns_urlencode -part query a@b

The full query parameter pair should be encoded with

  set pair [ns_urlencode -part query $key]=[ns_urlencode -part query $value]

RFC 3986 mentions explicitly the at-sign here:

  pchar   = unreserved / pct-encoded / sub-delims / ":" / "@"
  query   = *( pchar / "/" / "?" )

The JavaScript definition is rather vague about the meaning of a URI 
component; the closest thing in the RFC are path segments and query 
components. Since these two kind of components are defined differently 
in RFC 3986, it is clear that encodeURIComponent() does not follow the 
definition in RFC 3986. JavaScript has actually its own definition of 
"Universal Resource Identifier Character Classes" (see Annex 7 in [1]), 
which encodes more than necessary (probably JavaScript does not want to 
release a new version whenever the RFC is updated). The document states 
as well that the syntax of Uniform Resource Identifiers is based upon 
RFC 2396 (sect 18.2.6.1.2)


   /This syntax of Uniform Resource Identifiers is based upon RFC 2396
   and does not reflect the more recent RFC 3986 which replaces RFC
   2396. A formal description and implementation of UTF-8 is given in
   RFC 3629./

On an other place (section B.2.1.1, definition of escape), it states:

   /The encoding is partly based on the encoding described in RFC 1738,
   but the entire encoding specified in this standard is described
   above without regard to the contents of RFC 1738. This encoding does
   not reflect changes to RFC 1738 made by RFC 3986./

An encoding-set agnostic percent decoder decodes everything, so this 
works in practice. No recent web software should have problems with 
standard-compliant URIs, as produced by NaviServer.


Why are you asking?

all the best
-gn

[1] 
https://262.ecma-international.org/9.0/#sec-universal-resource-identifier-character-classes

On 25.08.21 08:21, Wolfgang Winkler via naviserver-devel wrote:


Dear List!

When using ns_urlencode, I've noticed, that the "@" sign will not be 
percent encoded, unless "-part oauth1" is stated:


ns_urlencode t...@test.com
t...@test.com

ns_urlencode -part oauth1 t...@test.com
test%40test.com

What is the correct way to encode URL params, e.g. in

http://test.com/register/login?email=t...@test.com

In Javascript (Chrome + Firefox)

encodeURIComponent("t...@test.com");

yields

"test%40test.com"

This is should be the RFC for this topic:

https://datatracker.ietf.org/doc/html/rfc3986#section-2.3

Yours,

Wolfgang

--

*Wolfgang Winkler*
Geschäftsführung
wolfgang.wink...@digital-concepts.com
mobil +43.699.19971172

dc:*büro*
digital concepts Novak Winkler OG
Software & Design
Landstraße 68, 5. Stock, 4020 Linz
www.digital-concepts.com 
tel +43.732.997117.72
tel +43.699.1997117.2

Firmenbuchnummer: 192003h
Firmenbuchgericht: Landesgericht Linz




___
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