I dug into the glitches seen on Windows... \e is a non-portable escape
(GNU extension), and shell escaping treats \n differently on Windows and
OS/2, which the testcase didn't account for.
I guess the code that used \e doesn't match anything in httpd?
--
Born in Roswell... married an alien...
http://emptyhammock.com/
Index: encoding/apr_escape.c
===================================================================
--- encoding/apr_escape.c (revision 1528671)
+++ encoding/apr_escape.c (working copy)
@@ -862,11 +862,6 @@
size++;
found = 1;
break;
- case '\e':
- *d++ = 'e';
- size++;
- found = 1;
- break;
case '\f':
*d++ = 'f';
size++;
@@ -931,7 +926,6 @@
switch (c) {
case '\a':
case '\b':
- case '\e':
case '\f':
case '\n':
case '\r':
Index: test/testescape.c
===================================================================
--- test/testescape.c (revision 1528671)
+++ test/testescape.c (working copy)
@@ -34,15 +34,33 @@
apr_pool_create(&pool, NULL);
+ src = "Hello World &;`'\"|*?~<>^()[]{}$\\";
+ target = "Hello World
\\&\\;\\`\\'\\\"\\|\\*\\?\\~\\<\\>\\^\\(\\)\\[\\]\\{\\}\\$\\\\";
+ dest = apr_pescape_shell(pool, src);
+ ABTS_ASSERT(tc,
+ apr_psprintf(pool, "shell escaped (%s) does not match expected
output (%s)",
+ dest, target),
+ (strcmp(dest, target) == 0));
+ apr_escape_shell(NULL, src, APR_ESCAPE_STRING, &len);
+ ABTS_ASSERT(tc,
+ apr_psprintf(pool, "size mismatch (%" APR_SIZE_T_FMT "!=%"
APR_SIZE_T_FMT ")", len, strlen(dest) + 1),
+ (len == strlen(dest) + 1));
+
+#if !(defined(OS2) || defined(WIN32))
+ /* Now try with newline, which is converted to a space on OS/2 and Windows.
+ */
src = "Hello World &;`'\"|*?~<>^()[]{}$\\\n";
target = "Hello World
\\&\\;\\`\\'\\\"\\|\\*\\?\\~\\<\\>\\^\\(\\)\\[\\]\\{\\}\\$\\\\\\\n";
dest = apr_pescape_shell(pool, src);
- ABTS_ASSERT(tc, "shell escaped matches expected output",
+ ABTS_ASSERT(tc,
+ apr_psprintf(pool, "shell escaped (%s) does not match expected
output (%s)",
+ dest, target),
(strcmp(dest, target) == 0));
apr_escape_shell(NULL, src, APR_ESCAPE_STRING, &len);
ABTS_ASSERT(tc,
apr_psprintf(pool, "size mismatch (%" APR_SIZE_T_FMT "!=%"
APR_SIZE_T_FMT ")", len, strlen(dest) + 1),
(len == strlen(dest) + 1));
+#endif
src = "Hello";
dest = apr_punescape_url(pool, src, NULL, NULL, 0);
@@ -196,8 +214,8 @@
dest = apr_pescape_echo(pool, src, 0);
ABTS_PTR_EQUAL(tc, src, dest);
- src = "\a\b\e\f\\n\r\t\v\"Hello World\"";
- target = "\\a\\b\\e\\f\\\\n\\r\\t\\v\"Hello World\"";
+ src = "\a\b\f\\n\r\t\v\"Hello World\"";
+ target = "\\a\\b\\f\\\\n\\r\\t\\v\"Hello World\"";
dest = apr_pescape_echo(pool, src, 0);
ABTS_STR_EQUAL(tc, target, dest);
apr_escape_echo(NULL, src, APR_ESCAPE_STRING, 0, &len);
@@ -205,8 +223,8 @@
apr_psprintf(pool, "size mismatch (%" APR_SIZE_T_FMT "!=%"
APR_SIZE_T_FMT ")", len, strlen(dest) + 1),
(len == strlen(dest) + 1));
- src = "\a\b\e\f\\n\r\t\v\"Hello World\"";
- target = "\\a\\b\\e\\f\\\\n\\r\\t\\v\\\"Hello World\\\"";
+ src = "\a\b\f\\n\r\t\v\"Hello World\"";
+ target = "\\a\\b\\f\\\\n\\r\\t\\v\\\"Hello World\\\"";
dest = apr_pescape_echo(pool, src, 1);
ABTS_STR_EQUAL(tc, target, dest);
apr_escape_echo(NULL, src, APR_ESCAPE_STRING, 1, &len);