[OpenAjaxIDE] HTML/JavaScript encoding for variable substitution
Jon Ferraiolo
jferrai at us.ibm.com
Wed Aug 13 11:08:32 PDT 2008
Right now we have both property substitution using @@foo@@ syntax and
localization substitution using %%bar%%. Kin has asked if we can extend the
syntax to take into account the fact that a given substitution string might
appear within HTML content (which has its own syntax quirks) and other
times within JavaScript (with its own syntax quirks). I promised to send an
email with a proposal.
Here is what I propose - add two optional parenthetical prefixes,
(htmlchars) and (jschars) to variable references, where:
(htmlchars) transforms the substitution string to the following
replacements (aligns with PHP's htmlspecialchars()):
& with &
< with <;
> with >;
" with "
' with '
(jschars) transforms the substitution string to the following replacements
(aligns with PHP's addslashes()):
\ with \\
' with \'
" with \"
To illustrate (htmlchars), suppose your have:
<content>@@(htmlchars)remark@@</content>
and the user entered the following for the remark property: << I'm in love!
>>
then the resulting content would be: << I'm in love! >>
To illustrate (jschars), suppose you have:
<javascript>document.getElementById
('textfield').value='@@(jschars)remark@@';</javascript>
then the resulting JavaScript would be: document.getElementById
('textfield').value='<< I\'m in love! >>';
I propose a variable reference can have either (htmlchars) or (jschars) or
neither, but not both.
Comments?
Jon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://openajax.org/pipermail/ide/attachments/20080813/89f98061/attachment-0001.html
More information about the IDE
mailing list