Forum OpenACS Development: Re: ad_quotehtml speed improvement
In fact, Ns_QuoteHtml translates these 5 different characters to their equivalent HTML entitites:
each become, respectively:< > & \ "
< > & ' "
Note that ns_quotehtml is translating literal backslashes, while ad_quotehtml is not. Why or why not?
So while you're at it, it would also useful to compare the string map vs. ns_quotehtml performance. If they're similar I think string map should be preferred, as it's much more general and powerful, and avoids and unnecessary dependency on the Ns_QuoteHtml C code for anyone trying to use OpenACS Tcl procs outside of AOLserver.
The problem is, as far as I can see, the only reason why you would want to quote quotes, in within html-tags and especially links. But, at least within links, that is not correct at all... Why?
As you see, I'm using single quotes. This is perfectly legal, and often usefull because single quotes do not have any special meaning in Tcl. For example:
This is a text where some values like this one $var1 will be inserted automatically [funca]
Because of this property, I've learned myself to write html using single quotes and so I can code adp like above in all my vanilla AOLserver code.
So, do we want to quote ' too? It would solve the problem.
# For simplicity of example, would normally be done in .tcl file
set name "Daniël Mantione"
Whoops! Afaik, an URL should in all situation consist of standard US-Ascii. It is no solution to quote, ë won't work in a URL.
What should be done instead? This is, of course, ns_urlencode. This is true in any situation where a variable is being expanded within a tag attribute that specifies a URL. (I.e. A href, IMG src, LINK href etc...)
Unless there is another reason to quote ", the entire reason why it should be quoted is bogus...
case '\'':in the C code last time around.
The Ns_QuoteHtml function appears to be identical in AOLserver 3.3+ad13 and the current AOLserver 4.0 CVS head.