User tests: Successful: Unsuccessful:
This should take care titles that contain quotes
Make sure that nothing breaks
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
Found a not-so-elegant solution in the layout...
<h3><?php echo str_replace("\'", "'", $params['title']); ?></h3>
That looks wrong. There must be a better way.
That looks wrong. There must be a better way.
I hope so... that's why I wrote a "not-so-elegant" solution...
just curious, what wrong with $this->escape($params['title'])
?
that would work indeed
Hi, some further infos here, the problem comes from this line:
https://github.com/joomla/joomla-cms/blob/staging/layouts/joomla/modal/main.php#L73
Following @infograf768 solution (reversed) solves the problem without the need to add all those true switches to each JText.
Also this is 100% B/C
One tester more to get this merged
Instead of using a custom preg_replace, please use the native function addslashes()
.
And then test also with double quotes "
and backslashes \
as those will be escaped by this method as well.
I tested it locally and it worked fine.
@Bakual @infograf768 done!
OK here!
All looking OK here. Setting to RTC as we have 2 successful tests.
Status | Pending | ⇒ | Ready to Commit |
Status | Ready to Commit | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-09-14 05:19:05 |
Closed_By | ⇒ | rdeutz |
Milestone |
Added: |
I think @Fedik 's suggestion
$this->escape()
which is:
htmlspecialchars(..., ENT_COMPAT, 'UTF-8');
is the prefered way to encode HTML Tag parameters:
so this should better
$iframeAttributes['name'] = htmlspecialchars($params['title'], ENT_COMPAT, 'UTF-8');
which will
i mean it is used inside Joomla and extensions code extensively to encode HTML Tag parameters, why this is an exception ?
i am not sure )) that is why my post was a question
i am often wrong too ))
i noted that in other places we are escaping the value of an HTML tag parameters in different way
The thing here is that the string has to be escaped for JavaScript not for html, so I'm not sure if your suggestion will work. Currently I'm not at my desk so I cannot test it....
addslashes will work for javascript
i am asking if it can break some UTF-8 characters making some words appear mispelled ?
from what i read if it is given a valid UTF-8 string, then the string will not break
it will skip single quotes
The only issue was the single quote which needs to be escaped for JS. Otherwise JS thinks the string ends and the code is broken. So your suggestion would not work.
you only need to escape (at least) double quotes to get parseable HTML
<iframe name="text_with_escaped_double_quotes" ...>
and for valid HTML (not just parsable) use on the HTML Tag parameter values
htmlspecialchars(..., ENT_COMPAT, 'UTF-8');
but then i see that HTML created by the ...\modal.php
SORRY i missed that !, so yes you are right, (as i said i am often wrong)
just a note, i think it would be best that HTML creation in template is more consistent
do escaping of single quotes at the place that PHP code is creating the JS code
thus avoid workarounds like this, and also if modal.php is updated in the future, nothing will break
e.g. if some adds a single quote anywhere, not just inside the HTML parameter values, but anywhere
anyway current solution works and is B/C, no need to change something
@dgt41
thanks for your contribution, i am sorry i meant nothing wrong about your works
i wish i could contribute just i am involved in with 2 web softwares with too large code base
i need to update my own code and removed deprecated stuff
a reason for the comment, is that i remember my modals sometimes being broken (i don't remember why), and i ended up replacing them with jQuery modals
Milestone |
Milestone |
Added: |
Milestone |
Added: |
Milestone |
This does not work here: it adds a slash before the single quote:
For example, when editing a single article menu item and using:
COM_CONTENT_CHANGE_ARTICLE="Sélectionner ou changer l'article"
The modal now loads OK but I get, for its title