| 1810 | } |
| 1811 | |
| 1812 | AP_DECLARE(char *) ap_escape_shell_cmd(apr_pool_t *p, const char *str) |
| 1813 | { |
| 1814 | char *cmd; |
| 1815 | unsigned char *d; |
| 1816 | const unsigned char *s; |
| 1817 | |
| 1818 | cmd = apr_palloc(p, 2 * strlen(str) + 1); /* Be safe */ |
| 1819 | d = (unsigned char *)cmd; |
| 1820 | s = (const unsigned char *)str; |
| 1821 | for (; *s; ++s) { |
| 1822 | |
| 1823 | #if defined(OS2) || defined(WIN32) |
| 1824 | /* |
| 1825 | * Newlines to Win32/OS2 CreateProcess() are ill advised. |
| 1826 | * Convert them to spaces since they are effectively white |
| 1827 | * space to most applications |
| 1828 | */ |
| 1829 | if (*s == '\r' || *s == '\n') { |
| 1830 | *d++ = ' '; |
| 1831 | continue; |
| 1832 | } |
| 1833 | #endif |
| 1834 | |
| 1835 | if (TEST_CHAR(*s, T_ESCAPE_SHELL_CMD)) { |
| 1836 | *d++ = '\\'; |
| 1837 | } |
| 1838 | *d++ = *s; |
| 1839 | } |
| 1840 | *d = '\0'; |
| 1841 | |
| 1842 | return cmd; |
| 1843 | } |
| 1844 | |
| 1845 | static char x2c(const char *what) |
| 1846 | { |
no outgoing calls
no test coverage detected