mirror of
https://github.com/php/php-src.git
synced 2026-04-04 22:52:40 +02:00
Use char literals in HTML numeric entity {en,de}coding functions
This commit is contained in:
@@ -2112,8 +2112,8 @@ collector_encode_htmlnumericentity(int c, void *data)
|
||||
if (c >= mapelm[0] && c <= mapelm[1]) {
|
||||
s = (c + mapelm[2]) & mapelm[3];
|
||||
if (s >= 0) {
|
||||
(*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
|
||||
(*pc->decoder->filter_function)(0x23, pc->decoder); /* '#' */
|
||||
(*pc->decoder->filter_function)('&', pc->decoder);
|
||||
(*pc->decoder->filter_function)('#', pc->decoder);
|
||||
r = 100000000;
|
||||
s %= r;
|
||||
while (r > 0) {
|
||||
@@ -2127,9 +2127,9 @@ collector_encode_htmlnumericentity(int c, void *data)
|
||||
}
|
||||
if (!f) {
|
||||
f = 1;
|
||||
(*pc->decoder->filter_function)(mbfl_hexchar_table[0], pc->decoder);
|
||||
(*pc->decoder->filter_function)('0', pc->decoder);
|
||||
}
|
||||
(*pc->decoder->filter_function)(0x3b, pc->decoder); /* ';' */
|
||||
(*pc->decoder->filter_function)(';', pc->decoder);
|
||||
}
|
||||
}
|
||||
if (f) {
|
||||
@@ -2152,38 +2152,38 @@ collector_decode_htmlnumericentity(int c, void *data)
|
||||
|
||||
switch (pc->status) {
|
||||
case 1:
|
||||
if (c == 0x23) { /* '#' */
|
||||
if (c == '#') {
|
||||
pc->status = 2;
|
||||
} else {
|
||||
pc->status = 0;
|
||||
(*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
|
||||
(*pc->decoder->filter_function)('&', pc->decoder);
|
||||
(*pc->decoder->filter_function)(c, pc->decoder);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (c == 0x78) { /* 'x' */
|
||||
if (c == 'x') {
|
||||
pc->status = 4;
|
||||
} else if (c >= 0x30 && c <= 0x39) { /* '0' - '9' */
|
||||
pc->cache = c - 0x30;
|
||||
} else if (c >= '0' && c <= '9') {
|
||||
pc->cache = c - '0';
|
||||
pc->status = 3;
|
||||
pc->digit = 1;
|
||||
} else {
|
||||
pc->status = 0;
|
||||
(*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
|
||||
(*pc->decoder->filter_function)(0x23, pc->decoder); /* '#' */
|
||||
(*pc->decoder->filter_function)('&', pc->decoder);
|
||||
(*pc->decoder->filter_function)('#', pc->decoder);
|
||||
(*pc->decoder->filter_function)(c, pc->decoder);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
s = 0;
|
||||
f = 0;
|
||||
if (c >= 0x30 && c <= 0x39) { /* '0' - '9' */
|
||||
if (c >= '0' && c <= '9') {
|
||||
s = pc->cache;
|
||||
if (pc->digit > 9 || s > INT_MAX/10) {
|
||||
pc->status = 0;
|
||||
f = 1;
|
||||
} else {
|
||||
s = s*10 + (c - 0x30);
|
||||
s = s*10 + (c - '0');
|
||||
pc->cache = s;
|
||||
pc->digit++;
|
||||
}
|
||||
@@ -2199,7 +2199,7 @@ collector_decode_htmlnumericentity(int c, void *data)
|
||||
if (d >= mapelm[0] && d <= mapelm[1]) {
|
||||
f = 0;
|
||||
(*pc->decoder->filter_function)(d, pc->decoder);
|
||||
if (c != 0x3b) { /* ';' */
|
||||
if (c != ';') {
|
||||
(*pc->decoder->filter_function)(c, pc->decoder);
|
||||
}
|
||||
break;
|
||||
@@ -2208,8 +2208,8 @@ collector_decode_htmlnumericentity(int c, void *data)
|
||||
}
|
||||
}
|
||||
if (f) {
|
||||
(*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
|
||||
(*pc->decoder->filter_function)(0x23, pc->decoder); /* '#' */
|
||||
(*pc->decoder->filter_function)('&', pc->decoder);
|
||||
(*pc->decoder->filter_function)('#', pc->decoder);
|
||||
r = 1;
|
||||
n = pc->digit;
|
||||
while (n > 1) {
|
||||
@@ -2226,43 +2226,41 @@ collector_decode_htmlnumericentity(int c, void *data)
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (c >= 0x30 && c <= 0x39) { /* '0' - '9' */
|
||||
pc->cache = c - 0x30;
|
||||
if (c >= '0' && c <= '9') {
|
||||
pc->cache = c - '0';
|
||||
pc->status = 5;
|
||||
pc->digit = 1;
|
||||
} else if (c >= 0x41 && c <= 0x46) { /* 'A' - 'F' */
|
||||
pc->cache = c - 0x41 + 10;
|
||||
} else if (c >= 'A' && c <= 'F') {
|
||||
pc->cache = c - 'A' + 10;
|
||||
pc->status = 5;
|
||||
pc->digit = 1;
|
||||
} else if (c >= 0x61 && c <= 0x66) { /* 'a' - 'f' */
|
||||
pc->cache = c - 0x61 + 10;
|
||||
} else if (c >= 'a' && c <= 'f') {
|
||||
pc->cache = c - 'a' + 10;
|
||||
pc->status = 5;
|
||||
pc->digit = 1;
|
||||
} else {
|
||||
pc->status = 0;
|
||||
(*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
|
||||
(*pc->decoder->filter_function)(0x23, pc->decoder); /* '#' */
|
||||
(*pc->decoder->filter_function)(0x78, pc->decoder); /* 'x' */
|
||||
(*pc->decoder->filter_function)('&', pc->decoder);
|
||||
(*pc->decoder->filter_function)('#', pc->decoder);
|
||||
(*pc->decoder->filter_function)('x', pc->decoder);
|
||||
(*pc->decoder->filter_function)(c, pc->decoder);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
s = 0;
|
||||
f = 0;
|
||||
if ((c >= 0x30 && c <= 0x39) ||
|
||||
(c >= 0x41 && c <= 0x46) ||
|
||||
(c >= 0x61 && c <= 0x66)) { /* '0' - '9' or 'a' - 'f' */
|
||||
if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')) {
|
||||
if (pc->digit > 9) {
|
||||
pc->status = 0;
|
||||
s = pc->cache;
|
||||
f = 1;
|
||||
} else {
|
||||
if (c >= 0x30 && c <= 0x39) {
|
||||
s = pc->cache*16 + (c - 0x30);
|
||||
} else if (c >= 0x41 && c <= 0x46) {
|
||||
s = pc->cache*16 + (c - 0x41 + 10);
|
||||
if (c >= '0' && c <= '9') {
|
||||
s = pc->cache*16 + (c - '0');
|
||||
} else if (c >= 'A' && c <= 'F') {
|
||||
s = pc->cache*16 + (c - 'A' + 10);
|
||||
} else {
|
||||
s = pc->cache*16 + (c - 0x61 + 10);
|
||||
s = pc->cache*16 + (c - 'a' + 10);
|
||||
}
|
||||
pc->cache = s;
|
||||
pc->digit++;
|
||||
@@ -2279,7 +2277,7 @@ collector_decode_htmlnumericentity(int c, void *data)
|
||||
if (d >= mapelm[0] && d <= mapelm[1]) {
|
||||
f = 0;
|
||||
(*pc->decoder->filter_function)(d, pc->decoder);
|
||||
if (c != 0x3b) { /* ';' */
|
||||
if (c != ';') {
|
||||
(*pc->decoder->filter_function)(c, pc->decoder);
|
||||
}
|
||||
break;
|
||||
@@ -2288,9 +2286,9 @@ collector_decode_htmlnumericentity(int c, void *data)
|
||||
}
|
||||
}
|
||||
if (f) {
|
||||
(*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
|
||||
(*pc->decoder->filter_function)(0x23, pc->decoder); /* '#' */
|
||||
(*pc->decoder->filter_function)(0x78, pc->decoder); /* 'x' */
|
||||
(*pc->decoder->filter_function)('&', pc->decoder);
|
||||
(*pc->decoder->filter_function)('#', pc->decoder);
|
||||
(*pc->decoder->filter_function)('x', pc->decoder);
|
||||
r = 1;
|
||||
n = pc->digit;
|
||||
while (n > 0) {
|
||||
@@ -2309,7 +2307,7 @@ collector_decode_htmlnumericentity(int c, void *data)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (c == 0x26) { /* '&' */
|
||||
if (c == '&') {
|
||||
pc->status = 1;
|
||||
} else {
|
||||
(*pc->decoder->filter_function)(c, pc->decoder);
|
||||
@@ -2334,9 +2332,9 @@ collector_encode_hex_htmlnumericentity(int c, void *data)
|
||||
if (c >= mapelm[0] && c <= mapelm[1]) {
|
||||
s = (c + mapelm[2]) & mapelm[3];
|
||||
if (s >= 0) {
|
||||
(*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
|
||||
(*pc->decoder->filter_function)(0x23, pc->decoder); /* '#' */
|
||||
(*pc->decoder->filter_function)(0x78, pc->decoder); /* 'x' */
|
||||
(*pc->decoder->filter_function)('&', pc->decoder);
|
||||
(*pc->decoder->filter_function)('#', pc->decoder);
|
||||
(*pc->decoder->filter_function)('x', pc->decoder);
|
||||
r = 0x1000000;
|
||||
s %= r;
|
||||
while (r > 0) {
|
||||
@@ -2350,9 +2348,9 @@ collector_encode_hex_htmlnumericentity(int c, void *data)
|
||||
}
|
||||
if (!f) {
|
||||
f = 1;
|
||||
(*pc->decoder->filter_function)(mbfl_hexchar_table[0], pc->decoder);
|
||||
(*pc->decoder->filter_function)('0', pc->decoder);
|
||||
}
|
||||
(*pc->decoder->filter_function)(0x3b, pc->decoder); /* ';' */
|
||||
(*pc->decoder->filter_function)(';', pc->decoder);
|
||||
}
|
||||
}
|
||||
if (f) {
|
||||
@@ -2375,15 +2373,15 @@ int mbfl_filt_decode_htmlnumericentity_flush(mbfl_convert_filter *filter)
|
||||
if (pc->status) {
|
||||
switch (pc->status) {
|
||||
case 1: /* '&' */
|
||||
(*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
|
||||
(*pc->decoder->filter_function)('&', pc->decoder);
|
||||
break;
|
||||
case 2: /* '#' */
|
||||
(*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
|
||||
(*pc->decoder->filter_function)(0x23, pc->decoder); /* '#' */
|
||||
(*pc->decoder->filter_function)('&', pc->decoder);
|
||||
(*pc->decoder->filter_function)('#', pc->decoder);
|
||||
break;
|
||||
case 3: /* '0'-'9' */
|
||||
(*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
|
||||
(*pc->decoder->filter_function)(0x23, pc->decoder); /* '#' */
|
||||
(*pc->decoder->filter_function)('&', pc->decoder);
|
||||
(*pc->decoder->filter_function)('#', pc->decoder);
|
||||
|
||||
s = pc->cache;
|
||||
r = 1;
|
||||
@@ -2401,14 +2399,14 @@ int mbfl_filt_decode_htmlnumericentity_flush(mbfl_convert_filter *filter)
|
||||
|
||||
break;
|
||||
case 4: /* 'x' */
|
||||
(*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
|
||||
(*pc->decoder->filter_function)(0x23, pc->decoder); /* '#' */
|
||||
(*pc->decoder->filter_function)(0x78, pc->decoder); /* 'x' */
|
||||
(*pc->decoder->filter_function)('&', pc->decoder);
|
||||
(*pc->decoder->filter_function)('#', pc->decoder);
|
||||
(*pc->decoder->filter_function)('x', pc->decoder);
|
||||
break;
|
||||
case 5: /* '0'-'9','a'-'f' */
|
||||
(*pc->decoder->filter_function)(0x26, pc->decoder); /* '&' */
|
||||
(*pc->decoder->filter_function)(0x23, pc->decoder); /* '#' */
|
||||
(*pc->decoder->filter_function)(0x78, pc->decoder); /* 'x' */
|
||||
(*pc->decoder->filter_function)('&', pc->decoder);
|
||||
(*pc->decoder->filter_function)('#', pc->decoder);
|
||||
(*pc->decoder->filter_function)('x', pc->decoder);
|
||||
|
||||
s = pc->cache;
|
||||
r = 1;
|
||||
|
||||
Reference in New Issue
Block a user