Jeff VIP
Total posts: 745
10 Aug 2015 07:01

Hi,

it seems I am unable to filter on values that have a single quote in it. Can this be fixed?

Error: SyntaxError: missing ) after argument list
Source File:  http://mysite.com/view 
Line: 1, Column: 50
Source Code:
Cobalt.setHiddenSelectableFlt7(this.id, 'children's author')

Best regards, Jeff

Last Modified: 03 Jan 2021


Sergey
Total posts: 13,748
10 Aug 2015 07:18

Fixed. If you what to fix it before update open field filter template toggle_links.php and find there

<?php echo htmlspecialchars($value->field_value);?>

and change to

<?php echo htmlspecialchars($value->field_value, ENT_QUOTES);?>

it should be somewhere around line 20.


Jeff VIP
Total posts: 745
10 Aug 2015 08:43

Hmmmmm.

It doesn't seem to translate anything.

I also tried

<?php echo htmlentities($value->field_value, ENT_QUOTES, 'UTF-8');?>

but to no avail either ;-(


Jeff VIP
Total posts: 745
10 Aug 2015 13:57

The only way I found to make it work is to add

$filter = preg_replace("/'/", "\&#39;", $value->field_value);

and replace

<?php echo htmlspecialchars($value->field_value);?>

with

<?php echo $filter ;?>

Sergey
Total posts: 13,748
10 Aug 2015 14:43

That is weird. single quotes have to be replaces with ENT_QUOTES


Jeff VIP
Total posts: 745
28 Sep 2015 00:17

Ah, I found a simpler solution by switching single quotes with double quotes and vice versa. I guess with the previous code a single quote in a search field caused the code to break.

<li <?php if(in_array($value->field_value, $default) ) echo "class='active'";?> id='flt-<?php echo $this->id;?>-<?php echo $key;?>' onclick='Cobalt.setHiddenSelectableFlt<?php echo $this->id;?>(this.id, "<?php echo htmlspecialchars($value->field_value, ENT_QUOTES);?>")'>

Sergey, could you please include this "fix" in the next update?


Sergey
Total posts: 13,748
29 Sep 2015 12:12

I could but this might give problems with bouble quotes in field value.

Please try this

echo addslashes(htmlspecialchars($value->field_value, ENT_QUOTES))

and if it works I'll add changes.


Jeff VIP
Total posts: 745
30 Sep 2015 06:54
echo addslashes(htmlspecialchars($value->field_value, ENT_QUOTES))

Didn't work for me.

But this one did!:

echo addslashes(htmlspecialchars($value->field_value))

Thanks, Sergey


Sergey
Total posts: 13,748
30 Sep 2015 13:24

Ok. Updated.

Powered by Cobalt