Uzbl

Tasklist

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
Task Type Bug Report
Category uzbl-browser & sample material
Status Assigned
Assigned To Robert (rob)
Operating System All
Severity Medium
Priority Normal
Reported Version Development
Due in Version Undecided
Due Date Undecided
Percent Complete 50%
Votes 0
Private No

Details

Scripts 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

Comment by Anonymous Submitter - 2009-12-18 06:44:49 AM
This is the reason we introduced the @''@ lexi expansion.

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.
Comment by Christophe-Marie Duquesne (chm.duquesne) - 2009-12-18 04:44:58 PM
I just tested it. I can grab " but not '.
Comment by Anonymous Submitter - 2009-12-18 10:06:13 PM
That is correct. As I said "This isn't working quite right at the moment". This is why the bug report is still open.
Comment by Christophe-Marie Duquesne (chm.duquesne) - 2009-12-19 08:27:19 AM
Yep, got it. I stay tuned.
Comment by Anonymous Submitter - 2009-12-20 02:26:42 PM
Ideally anything past the script location should be escaped and quoted and replace the '%s' occurrences in the script.
Comment by Anonymous Submitter - 2009-12-23 01:27:01 PM
I've just pushed a partial fix for this problem here: http://github.com/mason-larobina/uzbl/commit/09d59497d1c06f07b1915e34c0110401916231b9

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.

Loading...