Forum OpenACS Development: Re: ad_quotehtml speed improvement

Collapse
Posted by Daniël Mantione on
The discussion made me wonder why quotes need to be quoted...

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?

First example:

<A href='page?a=@a@&b=@b@'>

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]
<A href='page?a=${var2}&b=[funcb]'>blablbalbablablabl</A>
"%>

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.

Second example:

<%
# For simplicity of example, would normally be done in .tcl file
set name "Daniël Mantione"
%>
<A href='page?name=@name@'>blablablablablabla</A>

Whoops! Afaik, an URL should in all situation consist of standard US-Ascii. It is no solution to quote, &euml; 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...