You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@apr.apache.org by bu...@apache.org on 2008/10/30 04:13:00 UTC

DO NOT REPLY [Bug 46128] New: apr_tokenize_to_argv doesn't handle \" when preceded with a space or tab

https://issues.apache.org/bugzilla/show_bug.cgi?id=46128

           Summary: apr_tokenize_to_argv doesn't handle \" when preceded
                    with a space or tab
           Product: APR
           Version: HEAD
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: APR
        AssignedTo: bugs@apr.apache.org
        ReportedBy: eddie@omegaware.com


Created an attachment (id=22793)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=22793)
Patch to fix apr_tokenize_to_argv

given this input string
cat << EOL
> String String 123456 "Quoted String" "Quoted with a \"escaped quote\""
EOL


and running the string through apr_tokenize_to_argv.

apr_tokenize_to_argv(inputstr, &argv, pool);

When dumping argv it looks like this

argv[0] = "String";
argv[1] = "String";
argv[2] = "123456";
argv[3] = "Quoted String";
argv[4] = "Quoted with ";
argv[5] = "escaped quote\"";

Instead of

argv[0] = "String";
argv[1] = "String";
argv[2] = "123456";
argv[3] = "Quoted String";
argv[4] = "Quoted with \"escaped quote\"";

I've narrowed it down to line 117 last changed in revision 60398 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=60398 ) (ie. July of
2000)

The way the code reads is (expanded out)
1) IF the string is quoted and the current character is a space OR a tab, then
skip the next character and continue
  - OR -
2) IF the current character is a backslash (\) and the next character is one of
(space, tab, double quote, or single quote) then skip the next character and
continue.

The problem is the first major OR clause should JUST continue and NOT skip the
next character (which in the sample string above is the backslash in front of
the double quote).

So that first IF block should have the first or clause removed completely, as
the second if statement also does a check for "not" that scenario so it won't
break;


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


DO NOT REPLY [Bug 46128] apr_tokenize_to_argv doesn't handle \" when preceded with a space or tab

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46128





--- Comment #2 from Bojan Smojver <bo...@rexursive.com>  2008-11-10 00:41:25 PST ---
One other thing we may also want to fix is handling of escapes inside quotes.
Normally, if you have those inside quotes, they'll not be interpreted as
escapes, but as literals. In other words, something like this:

./run "Today\ is\ a\ nice\ day"

Will preserve backslashes for the program. However, this will not:

./run Today\ is\ a\ nice\ day

We hose backslashes in both cases (which is not the result of your patch, it
was always like this).


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


DO NOT REPLY [Bug 46128] apr_tokenize_to_argv doesn't handle \" when preceded with a space or tab

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46128


Bojan Smojver <bo...@rexursive.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


DO NOT REPLY [Bug 46128] apr_tokenize_to_argv doesn't handle \" when preceded with a space or tab

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46128


Bojan Smojver <bo...@rexursive.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bojan@rexursive.com




--- Comment #1 from Bojan Smojver <bo...@rexursive.com>  2008-11-10 00:11:17 PST ---
Yeah, I get you point. There is no need to skip an extra character if a space
or tab is found inside quotes (the loop will just bump the pointer up in due
course). As it is, backslash gets skipped, therefore missing the escape.

I will commit to trunk. Thanks for the patch!


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org