apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From minf...@apache.org
Subject svn commit: r1530786 - in /apr/apr/trunk: encoding/apr_escape.c include/apr_escape.h test/testescape.c
Date Wed, 09 Oct 2013 20:33:15 GMT
Author: minfrin
Date: Wed Oct  9 20:33:15 2013
New Revision: 1530786

URL: http://svn.apache.org/r1530786
Log:
Remove non-portable escaping of the escape character in apr_escape_echo(). Ensure
test case runs correctly on Windows and OS/2.

Modified:
    apr/apr/trunk/encoding/apr_escape.c
    apr/apr/trunk/include/apr_escape.h
    apr/apr/trunk/test/testescape.c

Modified: apr/apr/trunk/encoding/apr_escape.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/encoding/apr_escape.c?rev=1530786&r1=1530785&r2=1530786&view=diff
==============================================================================
--- apr/apr/trunk/encoding/apr_escape.c (original)
+++ apr/apr/trunk/encoding/apr_escape.c Wed Oct  9 20:33:15 2013
@@ -862,11 +862,6 @@ APR_DECLARE(apr_status_t) apr_escape_ech
                         size++;
                         found = 1;
                         break;
-                    case '\e':
-                        *d++ = 'e';
-                        size++;
-                        found = 1;
-                        break;
                     case '\f':
                         *d++ = 'f';
                         size++;
@@ -931,7 +926,6 @@ APR_DECLARE(apr_status_t) apr_escape_ech
                     switch (c) {
                     case '\a':
                     case '\b':
-                    case '\e':
                     case '\f':
                     case '\n':
                     case '\r':

Modified: apr/apr/trunk/include/apr_escape.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/apr_escape.h?rev=1530786&r1=1530785&r2=1530786&view=diff
==============================================================================
--- apr/apr/trunk/include/apr_escape.h (original)
+++ apr/apr/trunk/include/apr_escape.h Wed Oct  9 20:33:15 2013
@@ -275,9 +275,8 @@ APR_DECLARE(const char *) apr_punescape_
 /**
  * Escape control characters in a string, as performed by the shell's
  * 'echo' command. Characters are replaced as follows:
- * \a alert (bell), \b backspace, \e an escape character, \f form feed,
- * \n new line, \r carriage return, \t horizontal tab, \v vertical tab,
- * \\ backslash.
+ * \a alert (bell), \b backspace, \f form feed, \n new line, \r carriage
+ * return, \t horizontal tab, \v vertical tab, \\ backslash.
  *
  * Any non ascii character will be encoded as '\xHH', where HH is the hex
  * code of the character.

Modified: apr/apr/trunk/test/testescape.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/testescape.c?rev=1530786&r1=1530785&r2=1530786&view=diff
==============================================================================
--- apr/apr/trunk/test/testescape.c (original)
+++ apr/apr/trunk/test/testescape.c Wed Oct  9 20:33:15 2013
@@ -34,15 +34,33 @@ static void test_escape(abts_case *tc, v
 
     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 @@ static void test_escape(abts_case *tc, v
     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 @@ static void test_escape(abts_case *tc, v
             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);



Mime
View raw message