By: ege
Date: 2011-02-19
Time: 23:50
|
htmlconv on form fieldsHi,
Wouldn't it be very nice if we had an htmlconv option for form fields? The issue is that there is no option for converting single quotes. For textareas I use yes+nobr, which is perfectly fine. But for input fields yes+nobr doesn't convert single quotes (' character) which is problematic as delimiting attributes with single quotes is perfectly valid in html. What I need is something like htmlconv=full (or htmlconv=formfield) which will convert all of the characters that are converted by 'yes', will NOT convent line breaks to br tags (nobr behavior), and will convert both double and single quotes so that the form is not broken. Maybe something like htmlconv=yes+nobr+quotes. But a one word would be much nicer :) What do you think? |
By: Skrol29
Date: 2011-02-20
Time: 00:01
|
Re: htmlconv on form fieldsHi Ege,
I have no issue with <input> fields because the default behavior of "htmlconv" does protect both simple quotes and double quotes. TBS uses the PHP function htmlspecialchars(), see http://www.php.net/manual/function.htmlspecialchars.php |
By: ege
Date: 2011-02-20
Time: 01:12
|
Re: htmlconv on form fieldsThanks for prompt reply.
htmlconv=yes doesn't convert single quotes. tbs might use htmlspecialchars but does it use ENT_QUOTES? It seems it doesn't. It seems it convets only double quotes. Am I wrong? |
By: Skrol29
Date: 2011-02-21
Time: 12:26
|
Re: htmlconv on form fieldsYou're right, simple quotes are not escaped. This means TBS by default assumes that you are using double quotes for attribute delimiters in both HTML and XML.
Is that a problem? Do you really need simple quotes for your attribute delimiters? |
By: ege
Date: 2011-02-21
Time: 13:56
|
Re: htmlconv on form fieldsWell, since I now know how TBS behaves, I can code attributes with double quotes and ask my co-workers to do the same. In that sense, no, I don't REALLY need single quotes. But in HTML it is ok to use both single and double quotes, meaning now we have to think how TBS will behave when we write html. This is, in a way, a limiting factor and I guess that's the reason php's htmlspecialchars has 3 three options. I believe it would be nicer to have all possible options in TBS so the html coder is free from thinking "hmm, what if the template engine doesn't support single/double quotes?".
I have an assistant coder in the office who cuts designs into html + css. I realised the situation when I got the code from him and put TBS tags and data into it. Even though I REALLY don't need single quotes, I will have to tell him to replace all single quotes with double quotes for something he had actually done correctly. I still think something like htmlconv=attr would be very useful :) |
By: Skrol29
Date: 2011-02-22
Time: 22:40
|
Re: htmlconv on form fieldsHi Ege,
It is true that simple quotes are recognized by the HTML and XML specification as attribute delimiters. But TBS won't be able to go as deep as the HTML specification goes in flexibility. (XML is more strict, for example it does not allow unquoted attribute's values). Nevertheless I' studying your idea. In one hand it may be easy to implement, in the other hand it may be more complicated than just convert simple quotes because they are other specificities for attribute values which may be text or even Javascript. |
By: ege
Date: 2011-02-23
Time: 00:13
|
Re: htmlconv on form fieldsI certainly understand that, and that's why I suggested a new parameter for the situation. If you adjust the htmlconv=yes so that it starts to convert single quotes, you may break the existing code for whom relied on "old" functionality. I'm voting for htmlconv=attr :) It makes perfect sense to me: both quotes are converted, other html chars converted, newlines are not converted to <br />s.
Thanks for your interest. |