Ticket #482 (assigned defect)

Opened 1 year ago

Last modified 2 weeks ago

Saving translation of the user module from the manager results in corrupt file.

Reported by: DeCaf Assigned to: demian (accepted)
Priority: normal Milestone: 0.6.3
Component: module - default Severity: normal
Keywords: Cc:

Description

If a key contains an apostrophe (') in the translation file, this will not be escaped in the saved file, resulting in erroneous entries leading to (invisible) PHP errors and pages are not served. This scenario exists in the user module for the key:

$words['to enable the new user\'s account'] = 'för att aktivera det nya kontot';

Which when saved from the maintenance module results in:

$words['to enable the new user's account'] = 'för att aktivera det nya kontot';

which does not compile.

Change History

02/25/06 10:00:38 changed by werner

  • status changed from new to closed.
  • resolution set to fixed.

Fixed by #582 in [1550]

04/14/07 03:20:47 changed by ericpersson

Stripslashes in output seems to solve this problem, at least for database storage

Index: lib/SGL/Output.php
===================================================================
--- lib/SGL/Output.php  (revision 737)
+++ lib/SGL/Output.php  (working copy)
@@ -186,7 +186,7 @@
      */
     function translate($key, $filter = false, $aParams = array())
     {
-        $return = SGL_String::translate($key, $filter, $aParams);
+        $return = SGL_String::translate(stripslashes($key), $filter, $aParams);
         return stripslashes($return);
     }

04/15/07 17:19:24 changed by demian

  • status changed from closed to reopened.
  • resolution deleted.
  • milestone changed from 0.5.6 to 0.6.3.

improvements in Config i think will solve this

(in reply to: ↑ description ) 06/19/07 23:58:56 changed by xinhaozheng

  • owner changed from somebody to demian.
  • status changed from reopened to new.

Little changes in string and translation I thing will solve this problem,works well for trans stored in db and file.

Index: lib/SGL/String.php
===================================================================
--- lib/SGL/String.php	(revision 3204)
+++ lib/SGL/String.php	(working copy)
@@ -273,7 +273,8 @@
     {
         $c = &SGL_Config::singleton();
         $conf = $c->getAll();
-
+	
+	$key = addslashes($key);
         $trans = &$GLOBALS['_SGL']['TRANSLATION'];
         if (isset($trans[$key])) {
             if (!is_array($trans[$key])
Index: lib/SGL/Translation.php
===================================================================
--- lib/SGL/Translation.php	(revision 3204)
+++ lib/SGL/Translation.php	(working copy)
@@ -253,7 +253,7 @@
             foreach ($aTrans as $key => $value) {
                 $string = array($langID => $value);
-                $result = $trans->add(stripslashes($key), $module, $string);
+                $result = $trans->add($key, $module, $string);
                 if (is_a($result, 'PEAR_Error')) {
                     return $result;
@@ -265,7 +265,7 @@
             //  read translation data and get reference to root
             $c = new Config();
             foreach ($aTrans as $key => $value) {
-                $aTransStrip[stripslashes($key)] = $value;
+                $aTransStrip[$key] = $value;
             }
             $root = & $c->parseConfig($aTransStrip, 'phparray');
@@ -440,4 +440,4 @@
         return true;
     }
 }
-?>

06/27/07 08:38:57 changed by demian

  • status changed from new to assigned.

Hi xinhaozheng,

as per my comment, "improvements in PEAR::Config i think will solve this" - no point in adding a fix if upgrading Config will fix this, i will apply your patch if it doesn't however.