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

Gábor Hojtsy - December 28, 2007 - 01:16

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

meba - December 28, 2007 - 08:10

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

meba - December 28, 2007 - 08:31
Status:active» patch (code needs review)

JavaScript/AJAX don't like: quotes, newlines, carriage returns, tabs. Just escape them.

AttachmentSize
l10n_literals.patch1.47 KB

#4

Gábor Hojtsy - December 28, 2007 - 10:55

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

Gábor Hojtsy - February 23, 2008 - 12:11

Meba? What do you think?

#6

meba - March 5, 2008 - 19:11

Will look into this on Code Sprint...

#7

meba - March 7, 2008 - 18:13

OK, found drupal_to_js().

AttachmentSize
l10n_literals_to_js.patch1.39 KB

#8

Gábor Hojtsy - April 25, 2008 - 19:43
Status:patch (code needs review)» fixed

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

Anonymous (not verified) - May 9, 2008 - 19:51
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.