You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Grigorov (JIRA)" <ji...@apache.org> on 2014/03/05 13:21:44 UTC

[jira] [Resolved] (WICKET-5524) JavaScriptUtils.escapeQuotes() does not escape \

     [ https://issues.apache.org/jira/browse/WICKET-5524?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Grigorov resolved WICKET-5524.
-------------------------------------

    Resolution: Won't Fix

You can write you own helper method if this is a requirement for your use case.
#escapeQuotes() escapes ... quotes (single and double ones).

Your example {{Ulin Ni\'mah}} looks like already escaped string. If you do something like JavaScriptUtils.escapeQuotes(JavaScriptUtils.escapeQuotes(someString)) then it will produce something wrong!

Probably JavaScriptUtils.escapeQuotes() should not escape already escaped quotes ?! If you think this is better than please create a new ticket.

> JavaScriptUtils.escapeQuotes() does not escape \
> ------------------------------------------------
>
>                 Key: WICKET-5524
>                 URL: https://issues.apache.org/jira/browse/WICKET-5524
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 6.13.0
>            Reporter: Mahendri Winata
>
> We tried to use JavaScriptUtils.escapeQuotes like this:
> {code}
> @Override
> protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
> 	attributes.getAjaxCallListeners().add(new AjaxCallListener() {
> 		@Override
> 		public CharSequence getPrecondition(Component component) {
> 			return "return confirm('Anda yakin menghapus Cart " +
> 					JavaScriptUtils.escapeQuotes(item.getModel().getObject().getPerson().getName()) + " ini?')";
> 		}
> 	});
> 	super.updateAjaxAttributes(attributes);
> }
> {code}
> However this fails when the input is: (notice the backslash)
> {{Ulin Ni\'mah}}
> Because the output will be:
> {{Ulin Ni\\'mah}}
> {{escapeQuotes()}} should also escape backslashes in addition to quotes, so it is directly usable for writing JavaScript strings from arbitrary input.



--
This message was sent by Atlassian JIRA
(v6.2#6252)