View Issue Details

This bug affects 1 person(s).
 8
IDProjectCategoryView StatusLast Update
05875Bug reportsImport/Exportpublic2012-03-14 21:08
Reporterhugomp Assigned Tomagiclko 
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version1.92 
Fixed in Version1.92+ 
Summary05875: Flexible Labels do not register in french when apostrophes are in label text
Description

When saving Flexible Labels (French) with apostrophes in label text mySql produces an error and the saving does not work. Example: D'accord..., Pas d'accord..., etc.
Saving without apostrophes works OK.
My immediate solution to this is to save without apostrophes and add them directly after in the data base and it works OK.

TagsNo tags attached.
Bug heat8
Complete LimeSurvey version number (& build)120303
I will donate to the project if issue is resolvedNo
BrowserFF
Database type & versionMySQL: 5.0.77
Server OS (if known)Linux
Webserver software & version (if known)?
PHP Version5.2.14

Relationships

duplicate of 05830 closedmagiclko Quotes are not supported in label titles 

Users monitoring this issue

There are no users monitoring this issue.

Activities

c_schmitz

c_schmitz

2012-03-06 00:36

administrator   ~17736

Last edited: 2012-03-06 00:37

Not a security issue.
Shubhab, there is some strange function js2php used in updateset.js which crashes on a single quite(')
Can you check if this contruct can rather be replaced with a jQuery serialize() and modify it accordingly?
Or find some other way way to fix the quote issue.
Thank you!

hugomp

hugomp

2012-03-06 12:59

reporter   ~17745

I noticed that not only single quotes (') are a problem but also double quotes (").

DenisChenu

DenisChenu

2012-03-06 13:23

developer   ~17747

Hello,

editanswer and editsubquestion are OK.

Maybe use same function for label se edition is a good option.

Denis

magiclko

magiclko

2012-03-08 13:42

reporter   ~17788

Fixed in rev rc1ede9c - http://git.io/_PLpSw

hugomp

hugomp

2012-03-08 21:13

reporter   ~17795

I made the changes in the three files as indicated in above link.
It does not seem to work for me.
In fact, with the changes no data at all can be saved with or without quotes...

magiclko

magiclko

2012-03-09 09:13

reporter   ~17797

hugomp - version you are using? it works fine here!

c_schmitz

c_schmitz

2012-03-09 09:42

administrator   ~17798

Remember to clear your browser cache.

hugomp

hugomp

2012-03-09 10:48

reporter   ~17799

I tried again:
The changes made:

label.php:
//$data =json_decode(stripslashes($_POST['dataToSend']));
$data = json_decode(html_entity_decode($_POST['dataToSend'], ENT_QUOTES,"UTF-8"));

admin_core.js:
//json += '"'+property+'":"'+value+'",'
//escape double quotes!
value = value.replace(/"/g, '\"'); //.replace(/'/g, '\\'')
json += '"'+property+'":"'+value+'",';

updateset.js:
//$("#mainform").append("<input type='hidden' name='dataToSend' //value='"+js2php(dataToSend)+"' />");
var encodedData = htmlspecialchars(js2php(dataToSend));
$("#mainform").append("<input type='hidden' name='dataToSend' value='"+encodedData+"' />");

does not work for me even after clearing browser cache...
I get the warning:
Warning: array_unique() [function.array-unique]: The argument should be an array in /mnt/sites/pre-sales.ch/web/limesurvey/admin/labels.php on line 611

I am using version 1.92

magiclko

magiclko

2012-03-09 16:32

reporter   ~17806

hugomp : add this line

echo $_POST['dataToSend'];

above line no. 611 in admin/labels.php and tell me what do you get.

hugomp

hugomp

2012-03-09 16:43

reporter   ~17807

Here it is:

{\"langs\":[\"fr\"],\"codelist\":[\"0\",\"1\"],\"0\":{\"code\":\"1\",\"assessmentvalue\":\"0\",\"text_fr\":\"d\'accord\"},\"1\":{\"code\":\"2\",\"assessmentvalue\":\"0\",\"text_fr\":\"pas d\'accord\"}}

  • Warning as above
magiclko

magiclko

2012-03-09 18:20

reporter   ~17809

weird, i'm only escaping value and not property!
I'll have a look again.

hugomp

hugomp

2012-03-09 19:20

reporter   ~17810

Here is the site setting: http://www.pre-sales.ch/phpinfo.php
Could this have something to do with "magic quotes" and/or the french language?

magiclko

magiclko

2012-03-09 20:30

reporter   ~17811

Most probably, it's "magic_quotes_gpc=on". try setting it to off and it'll work i guess!

hugomp

hugomp

2012-03-09 22:29

reporter   ~17812

I have no access to php.ini but putting this code:

if (get_magic_quotes_gpc()) {
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
while (list($key, $val) = each($process)) {
foreach ($val as $k => $v) {
unset($process[$key][$k]);
if (is_array($v)) {
$process[$key][stripslashes($k)] = $v;
$process[] = &$process[$key][stripslashes($k)];
} else {
$process[$key][stripslashes($k)] = stripslashes($v);
}
}
}
unset($process);
}

at the top of the admin.php file...

...I can normally save label data WITHOUT any quote in the text (like before the changes) but putting quotes in it produces this time a MySql error.

Following "echo $_POST['dataToSend'];" I get:
{"langs":["fr"],"codelist":["0","new74039"],"0":{"code":"1","assessmentvalue":"0","text_fr":"d'accord"},"new74039":{"code":"2","assessmentvalue":"0","text_fr":"pas d'accord"}}

MySql error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'accord','0',0,'fr')' at line 2:INSERT INTO lime_labels (lid,code,title,sortorder, assessment_value, language) VALUES(5,'1','d'accord','0',0,'fr')

Wouldn't it make sens in the general coding of LimeSurvey to foresee both possibilities: 1)magic quotes on and 2)magic quotes off? Many providers with shared Apache Servers do not give access to php.ini.

hugomp

hugomp

2012-03-10 18:03

reporter   ~17816

A solution to eliminate the MySql error is for me:

$title = substr($title, 1, -1);
$title = str_replace("'","\'",$title);
$query = "INSERT INTO ".db_table_name('labels')." (lid,code,title,sortorder, assessment_value, language)
VALUES({$lid},{$actualcode},'{$title}',{$sort_order},{$assessmentvalue},{$lang})";

in labels.php around line 650 before and for the INSERT statament

c_schmitz

c_schmitz

2012-03-11 16:31

administrator   ~17824

1.92+ Build 120211 released

Related Changesets

LimeSurvey: Yii 69b720d8

2012-03-08 05:53:22

magiclko

Details Diff
Fixed issue 05875: Flexible Labels do not register in french when apostrophes are in label text. Affected Issues
05875
mod - application/helpers/admin/label_helper.php Diff File
mod - scripts/admin/updateset.js Diff File

Issue History

Date Modified Username Field Change
2012-03-05 13:48 hugomp New Issue
2012-03-05 21:36 c_schmitz Assigned To => c_schmitz
2012-03-05 21:36 c_schmitz Status new => assigned
2012-03-06 00:34 c_schmitz Assigned To c_schmitz => magiclko
2012-03-06 00:36 c_schmitz Note Added: 17736
2012-03-06 00:37 c_schmitz Note Edited: 17736
2012-03-06 08:51 magiclko Relationship added duplicate of 05830
2012-03-06 12:59 hugomp Note Added: 17745
2012-03-06 13:23 DenisChenu Note Added: 17747
2012-03-08 13:42 magiclko Note Added: 17788
2012-03-08 13:42 magiclko Status assigned => resolved
2012-03-08 13:42 magiclko Fixed in Version => 1.92+
2012-03-08 13:42 magiclko Resolution open => fixed
2012-03-08 21:13 hugomp Note Added: 17795
2012-03-09 09:13 magiclko Note Added: 17797
2012-03-09 09:42 c_schmitz Note Added: 17798
2012-03-09 10:48 hugomp Note Added: 17799
2012-03-09 16:32 magiclko Note Added: 17806
2012-03-09 16:43 hugomp Note Added: 17807
2012-03-09 18:20 magiclko Note Added: 17809
2012-03-09 19:20 hugomp Note Added: 17810
2012-03-09 20:30 magiclko Note Added: 17811
2012-03-09 22:29 hugomp Note Added: 17812
2012-03-10 18:03 hugomp Note Added: 17816
2012-03-11 16:31 c_schmitz Note Added: 17824
2012-03-11 16:31 c_schmitz Status resolved => closed
2012-03-14 21:08 magiclko Changeset attached => Import 2012-03-09 13:30:34 Yii 69b720d8