Editing a suggestion containing a newline causes javascript error
meba - December 27, 2007 - 23:21
| Project: | Localization server |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
unterminated string literal
[Break on this error] return l10nCommunity.copySuggestion(1283,'\n
#1
This might even be related to http://drupal.org/node/195421 although the error report is very vague there (and it was closed being totally without feedback).
#2
Source:
return l10nCommunity.copySuggestion(1283,' <p>Tento web povoluje HTML obsah. Možná vás děsí učení se HTML, ale naučit se používat několik málo nejzákladnějších HTML "značek" je velice snadné. Tato tabulka poskytuje příklady pro každou značku povolenou na tomto webu.</p> <p>Více informací najdete ve <a href="http://www.w3.org/TR/html/">specifikaci HTML</a> u W3C nebo si najděte jiné stránky, kde je HTML vysvětleno.</p>');#3
JavaScript/AJAX don't like: quotes, newlines, carriage returns, tabs. Just escape them.
#4
What if we reuse the same code as used by drupal_add_js() when we add the settings strings (ie. the edit buttons for the original strings and translations)? Even if it does not have reusable parts, we might still miss something here. Better to reuse that or steal from there as it is already proven to work :)
#5
Meba? What do you think?
#6
Will look into this on Code Sprint...
#7
OK, found drupal_to_js().
#8
Hm, I applied this patch and found a few issues:
- drupal_to_js() generates the quotes on its own, so we should not
- escaping \0 just ends up as \\0 (through drupal_to_js()'s addslashes()), which is not useful to us at all, since it should be \O (uppercase "oh" letter!)
This way it works again on my system and can copy plural suggestions to the edit field again. With your patch, due to these two errors, it did not (or in fact the first error just added the quotes into the string, the second stopped it from working).
I committed this edition of the patch: http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/l10n_server...
#9
Automatically closed -- issue fixed for two weeks with no activity.