FS#152 - Quotes are not passed properly to the scripts
Attached to Project:
Uzbl
Opened by Christophe-Marie Duquesne (chm.duquesne) - 2009-12-14 11:02:25 AM
Last edited by Anonymous Submitter - 2009-12-23 01:27:56 PM
Opened by Christophe-Marie Duquesne (chm.duquesne) - 2009-12-14 11:02:25 AM
Last edited by Anonymous Submitter - 2009-12-23 01:27:56 PM
|
DetailsScripts are not passed strings literally and miss some ' (single quote) and " (double quote).
How to reproduce: 1) save the following script as test_quotes.js in your uzbl script directory: //=== test if quotes are passed properly to javascript ===// function checkString(input){ var s = input.split(''); // we check the characters of the input one by one var readAquote = false; for (var k = 0; k < s.length; k++) { if (s[k] == '"') { readAquote = true; } if (s[k] == "'") { readAquote = true; } } // result of the test if (readAquote) { alert("We did read a quote in %s"); } else { alert("We did not see any quote in %s"); } }; checkString('%s'); //============================// 2) bind the script in your config file to <some key>* @bind q* = script @scripts_dir/test_quotes.js %s 3) in uzbl-browser, typing q" fails to detect any quote. However, if you add a subsequent ' (e.g. q"') it will detect a quote (the '). |
This task depends upon
Example (This isn't working quite right at the moment):
print @' some ' sdf' text " 'tfd's ' "" '@ -> ' some \' sdf\' text " \'tfd\'s \' "" '
So your bind would become:
@bind q* = script @scripts_dir/test_quotes.js @'%s'@
Which will take any input that doesn't contain a '@
The second avenue which I am going to pursue is the implementation of %r substitutions everywhere I have implemented %s substitutions which return escaped and quoted text (perfect for passing directly to javascript functions).
Stay tuned.
I've introduced the escaped and quoted replace %r into the on_event and bind plugins so you can:
@bind x_ = js alert(%r);
And be assured that what the javascript is receiving is exactly what you typed. This doesn't solve your script problem though.
If you do the following:
@bind x_ = script @scripts_dir/myscript.js %r
And your substitution line in your script looks like:
myFunction('%s');
It will become:
myFunction(''what ever you typed'');
So change it to:
myFunction(%s);
Let me know if you still have any problems.
Rob has also pushed http://github.com/robm/uzbl/commit/99da90d4f24cbef618868145d2482af8fa6e1f3b but I don't know how well this works yet.