Ticket #578: Xapian ticket 578 attachment.txt

File Xapian ticket 578 attachment.txt, 1.3 KB (added by Charles, 13 years ago)

Generating command and patch

Line 
1diff -Naur xapian-omega-1.2.7-original/cgiparam.cc xapian-omega-1.2.7/cgiparam.cc
2--- xapian-omega-1.2.7-original/cgiparam.cc 2011-08-10 09:49:12.000000000 +0300
3+++ xapian-omega-1.2.7/cgiparam.cc 2011-11-13 08:10:15.021566998 +0200
4@@ -180,20 +180,28 @@
5 while (1) {
6 ch = *q_str++;
7 if (ch == '\0' || ch == '&') {
8- if (name.empty()) return; // end on blank line
9- add_param(name, val);
10+ if (!name.empty()) add_param(name, val);
11+ if (ch == '\0')
12+ return;
13 break;
14 }
15 char orig_ch = ch;
16 if (ch == '+')
17 ch = ' ';
18- else if (ch == '%') {
19- int c = *q_str++;
20- ch = (c & 0xf) + ((c & 64) ? 9 : 0);
21- if (c) c = *q_str++;
22- ch = ch << 4;
23- ch |= (c & 0xf) + ((c & 64) ? 9 : 0);
24- if (!c) return; // unfinished % code
25+ else if (ch == '%' &&
26+ ((q_str[0] >= '0' && q_str[0] <= '9') ||
27+ (q_str[0] >= 'A' && q_str[0] <= 'F') ||
28+ (q_str[0] >= 'a' && q_str[0] <= 'f')) &&
29+ ((q_str[1] >= '0' && q_str[1] <= '9') ||
30+ (q_str[1] >= 'A' && q_str[1] <= 'F') ||
31+ (q_str[1] >= 'a' && q_str[1] <= 'f'))) {
32+ const int c1 = q_str[0], c2 = q_str[1];
33+ int c;
34+ c = ( (c1 & 0xf) + ((c1 & 64) ? 9 : 0) ) << 4
35+ + ( (c2 & 0xf) + ((c2 & 64) ? 9 : 0) );
36+ q_str += 2;
37+ if (!c)
38+ continue;
39 }
40 if (had_equals) {
41 val += char(ch);