]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/format/Quoting.cc
2 #include "format/Quoting.h"
4 static const char c2x
[] =
5 "000102030405060708090a0b0c0d0e0f"
6 "101112131415161718191a1b1c1d1e1f"
7 "202122232425262728292a2b2c2d2e2f"
8 "303132333435363738393a3b3c3d3e3f"
9 "404142434445464748494a4b4c4d4e4f"
10 "505152535455565758595a5b5c5d5e5f"
11 "606162636465666768696a6b6c6d6e6f"
12 "707172737475767778797a7b7c7d7e7f"
13 "808182838485868788898a8b8c8d8e8f"
14 "909192939495969798999a9b9c9d9e9f"
15 "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf"
16 "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf"
17 "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf"
18 "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf"
19 "e0e1e2e3e4e5e6e7e8e9eaebecedeeef"
20 "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff";
22 #if DEAD_USING_QUOTEMIMEBLOB
23 /** copy of Log::QuoteMimeBlob. Bugs there will be found here.
24 * This omits [] characters but is otherwise identical to Log::QuoteMimeBlob when OLD_LOG_MIME = 1
27 username_quote(const char *header
)
35 buf
= static_cast<char *>(xcalloc(1, 1));
40 buf
= static_cast<char *>(xcalloc(1, (strlen(header
) * 3) + 1));
43 * We escape: space \x00-\x1F and space (0x40) and \x7F-\xFF
44 * to prevent garbage in the logs. CR and LF are also there just in case.
47 while ((c
= *(const unsigned char *) header
++) != '\0') {
51 } else if (c
== '\n') {
60 *buf_cursor
++ = c2x
[i
];
61 *buf_cursor
++ = c2x
[i
+ 1];
63 *buf_cursor
++ = (char) c
;
73 Format::QuoteUrlEncodeUsername(const char *name
)
81 return QuoteMimeBlob(name
);
82 // return username_quote(name);
86 Format::QuoteMimeBlob(const char *header
)
94 buf
= static_cast<char *>(xcalloc(1, 1));
99 buf
= static_cast<char *>(xcalloc(1, (strlen(header
) * 3) + 1));
102 * Whe OLD_LOG_MIME is defined we escape: \x00-\x1F"#%;<>?{}|\\\\^~`\[\]\x7F-\xFF
103 * which is the default escape list for the CPAN Perl5 URI module
104 * modulo the inclusion of space (x40) to make the raw logs a bit
108 while ((c
= *(const unsigned char *) header
++) != '\0') {
111 *buf_cursor
++ = '\\';
113 } else if (c
== '\n') {
114 *buf_cursor
++ = '\\';
140 *buf_cursor
++ = c2x
[i
];
141 *buf_cursor
++ = c2x
[i
+ 1];
144 } else if (c
== '\\') {
145 *buf_cursor
++ = '\\';
146 *buf_cursor
++ = '\\';
150 *buf_cursor
++ = (char) c
;