FS#38 - Errors in parsing of useragent string.
Attached to Project:
Uzbl
Opened by Eric (Eric) - 2009-06-10 10:04:29 PM
Last edited by Dieter Plaetinck (Dieter_be) - 2009-07-17 07:17:43 PM
Opened by Eric (Eric) - 2009-06-10 10:04:29 PM
Last edited by Dieter Plaetinck (Dieter_be) - 2009-07-17 07:17:43 PM
|
DetailsThere is a problem in the parsing of the useragent string set in the config file. Any string that contains a letter directly following a number will cause problems. It will either truncate the user agent string or add "libsoup/2.26.2".
Example: set useragent = Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1b4) Gecko/20090528 Gentoo Firefox/3.5b4 Resulting User Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9. Example: set useragent = 7a Resulting User Agent: libsoup/2.26.2 |
This task depends upon
A solution is to enable scan_string_sq, add this to expand_template():
else if(token == G_TOKEN_STRING) {
g_string_append(ret, (gchar *)g_scanner_cur_value(uzbl.scan).v_string);
}
and do set useragent = 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1b4) Gecko/20090528 Gentoo Firefox/3.5b4'.
There doesn't seem to be a way to tell gscanner to ignore numbers. scan_string_dq might work too, but it interferes with the example status_format.
- Furthermore, you must now do things like:
set useragent = 'uzbl 7a (Webkit' WEBKIT_MAJOR.WEBKIT_MINOR.WEBKIT_MICRO)
which looks quite ugly. I hope we can figure out something cleaner that does not force the user to add quotes to variables that we already know are strings (see var_name_to_ptr and proto_var)
The commit linked below contains a replacement for gscanner. It's very basic, it doesn't do parsing of integers or floats or quoted strings or any of the other things that gscanner does. There's no UI change.
http://github.com/bct/uzbl/commit/202685865f8947c19baed2dfd539c145958c21ed
http://markmail.org/message/eymgig6gsjxyf2id?q=gscanner&page=8
I think it's a fair assumption that the same applies to integers too (and a quick skim of gscanner.c appears to confirm it). It looks like gscanner wasn't really meant for a usecase as simple as ours.
Too bad no one responded on your thread (http://www.spinics.net/lists/gtk/msg15370.html)
But I think the good news is we can use rob's little language that also supports variables. So we can get rid of gscanner and don't need to write a replacement for it anymore :)