mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 07:11:41 +00:00
Correctly parse octal escapes for plist strings.
It seems the code expected octal escapes to always start with 0. This is not the case. Also, octal escapes are limited to 3 digits (and hex to 2). This fixes the garbled bold text in ITS.
This commit is contained in:
parent
febb615580
commit
a4714ac9b5
1 changed files with 10 additions and 7 deletions
|
@ -526,7 +526,7 @@ PL_ParseQuotedString (pldata_t *pl)
|
|||
char c = pl->ptr[pl->pos];
|
||||
|
||||
if (escaped) {
|
||||
if (escaped == 1 && c == '0') {
|
||||
if (escaped == 1 && inrange (c, '0', '7')) {
|
||||
escaped++;
|
||||
hex = false;
|
||||
} else if (escaped > 1) {
|
||||
|
@ -534,10 +534,11 @@ PL_ParseQuotedString (pldata_t *pl)
|
|||
hex = true;
|
||||
shrink++;
|
||||
escaped++;
|
||||
} else if (hex && isxdigit ((byte) c)) {
|
||||
} else if (hex && inrange (escaped, 3, 4)
|
||||
&& isxdigit ((byte) c)) {
|
||||
shrink++;
|
||||
escaped++;
|
||||
} else if (c >= '0' && c <= '7') {
|
||||
} else if (inrange (escaped, 1, 3) && inrange (c, '0', '7')) {
|
||||
shrink++;
|
||||
escaped++;
|
||||
} else {
|
||||
|
@ -585,19 +586,21 @@ PL_ParseQuotedString (pldata_t *pl)
|
|||
char c = pl->ptr[j];
|
||||
|
||||
if (escaped) {
|
||||
if (escaped == 1 && c == '0') {
|
||||
chars[k] = 0;
|
||||
if (escaped == 1 && inrange (c, '0', '7')) {
|
||||
chars[k] = c - '0';
|
||||
hex = false;
|
||||
escaped++;
|
||||
} else if (escaped > 1) {
|
||||
if (escaped == 2 && c == 'x') {
|
||||
hex = true;
|
||||
escaped++;
|
||||
} else if (hex && isxdigit ((byte) c)) {
|
||||
} else if (hex && inrange (escaped, 3, 4)
|
||||
&& isxdigit ((byte) c)) {
|
||||
chars[k] <<= 4;
|
||||
chars[k] |= char2num (c);
|
||||
escaped++;
|
||||
} else if (inrange (c, '0', '7')) {
|
||||
} else if (inrange (escaped, 1, 3)
|
||||
&& inrange (c, '0', '7')) {
|
||||
chars[k] <<= 3;
|
||||
chars[k] |= (c - '0');
|
||||
escaped++;
|
||||
|
|
Loading…
Reference in a new issue