Escaping double quotes

Started by spiros, May 20, 2018, 07:50:04 AM

Previous topic - Next topic

spiros

I have this mod in subs.php which creates a Google search with a BBC code:

'content' => '<a href="https://www.google.com/search?q=$1" target="_blank">$1</a>',

And I want it instead of a simple search, to output a phrase search (in double quotes, I.e. "search phrase").

I tried this, but did not output any search.

'content' => '<a href="https://www.google.com/search?q=\"$1\"" target="_blank">$1</a>',

This is the context:

array(
'tag' => 'google',
'type' => 'unparsed_content',
'content' => '<a href="https://www.google.com/search?q=$1" target="_blank">$1</a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_content' => '<span style="color: red;">Google Search: $1</span>',
),
array(
'tag' => 'google',
'type' => 'unparsed_equals',
'before' => '<a href="https://www.google.com/search?q=$1" target="_blank">',
'after' => '</a>',
'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_before' => '<span style="color: red;">',
'disabled_after' => ' ($1)</span>',
),

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

spiros

Thanks, not sure how to apply it to that code.

d3vcho

Not sure without testing and all but - should be just doing urlencode($1)
"Greeting Death as an old friend, they departed this life as equals"

spiros

Thanks, tried this but resulted in searching backslash, am I escaping correctly here?

https://www.google.com/search?q=\

       array(
'tag' => 'google',
'type' => 'unparsed_content',
'content' => '<a href="https://www.google.com/search?q=\"$1\"" target="_blank">$1</a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
                'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_content' => '<span style="color: red;">Google Search: urlencode($1)</span>',
),
array(
'tag' => 'google',
'type' => 'unparsed_equals',
'before' => '<a href="https://www.google.com/search?q=\"$1\"" target="_blank">',
                'after' => '</a>',
                'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_before' => '<span style="color: red;">',
                'disabled_after' => ' urlencode($1)</span>',

Advertisement: