Skip to content

Commit 448f085

Browse files
committed
fix counting columns for utf-x characters
1 parent be47a53 commit 448f085

6 files changed

+35
-35
lines changed

ext/json/json_scanner.re

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,22 +270,22 @@ std:
270270
return PHP_JSON_T_ERROR;
271271
}
272272
<STR_P1>UTF16_1 {
273-
PHP_JSON_TOKEN_LOCATION(last_column) += 6;
273+
PHP_JSON_TOKEN_LOCATION(last_column) += 1; //6
274274
s->str_esc += 5;
275275
PHP_JSON_CONDITION_GOTO(STR_P1);
276276
}
277277
<STR_P1>UTF16_2 {
278-
PHP_JSON_TOKEN_LOCATION(last_column) += 6;
278+
PHP_JSON_TOKEN_LOCATION(last_column) += 1; //6
279279
s->str_esc += 4;
280280
PHP_JSON_CONDITION_GOTO(STR_P1);
281281
}
282282
<STR_P1>UTF16_3 {
283-
PHP_JSON_TOKEN_LOCATION(last_column) += 6;
283+
PHP_JSON_TOKEN_LOCATION(last_column) += 1; //6
284284
s->str_esc += 3;
285285
PHP_JSON_CONDITION_GOTO(STR_P1);
286286
}
287287
<STR_P1>UTF16_4 {
288-
PHP_JSON_TOKEN_LOCATION(last_column) += 12;
288+
PHP_JSON_TOKEN_LOCATION(last_column) += 1; //12
289289
s->str_esc += 8;
290290
PHP_JSON_CONDITION_GOTO(STR_P1);
291291
}
@@ -329,15 +329,15 @@ std:
329329
PHP_JSON_CONDITION_GOTO(STR_P1);
330330
}
331331
<STR_P1>UTF8_2 {
332-
PHP_JSON_TOKEN_LOCATION(last_column) += 2;
332+
PHP_JSON_TOKEN_LOCATION(last_column) += 1; //2
333333
PHP_JSON_CONDITION_GOTO(STR_P1);
334334
}
335335
<STR_P1>UTF8_3 {
336-
PHP_JSON_TOKEN_LOCATION(last_column) += 3;
336+
PHP_JSON_TOKEN_LOCATION(last_column) += 1; //3
337337
PHP_JSON_CONDITION_GOTO(STR_P1);
338338
}
339339
<STR_P1>UTF8_4 {
340-
PHP_JSON_TOKEN_LOCATION(last_column) += 4;
340+
PHP_JSON_TOKEN_LOCATION(last_column) += 1; //4
341341
PHP_JSON_CONDITION_GOTO(STR_P1);
342342
}
343343
<STR_P1>ANY {

ext/json/tests/bug68546.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ NULL
1616
bool(true)
1717
NULL
1818
bool(true)
19-
string(55) "The decoded property name is invalid near location 1,37"
19+
string(55) "The decoded property name is invalid near location 1,27"
2020
Done

ext/json/tests/json_last_error_msg_error_location_002.phpt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,22 @@ Testing error locations with Unicode UTF-8 characters
5454
Error after Japanese characters:
5555
bool(false)
5656
int(3)
57-
string(72) "Control character error, possibly incorrectly encoded near location 1,24"
57+
string(72) "Control character error, possibly incorrectly encoded near location 1,12"
5858

5959
Error after Russian characters:
6060
bool(false)
6161
int(3)
62-
string(72) "Control character error, possibly incorrectly encoded near location 1,12"
62+
string(71) "Control character error, possibly incorrectly encoded near location 1,9"
6363

6464
Error after Chinese characters:
6565
bool(false)
6666
int(3)
67-
string(72) "Control character error, possibly incorrectly encoded near location 1,12"
67+
string(71) "Control character error, possibly incorrectly encoded near location 1,8"
6868

6969
Error after Arabic characters:
7070
bool(false)
7171
int(3)
72-
string(72) "Control character error, possibly incorrectly encoded near location 1,12"
72+
string(71) "Control character error, possibly incorrectly encoded near location 1,9"
7373

7474
Error after Emoji:
7575
bool(false)
@@ -79,7 +79,7 @@ string(72) "Control character error, possibly incorrectly encoded near location
7979
Error in mixed ASCII and UTF-8:
8080
bool(false)
8181
int(3)
82-
string(72) "Control character error, possibly incorrectly encoded near location 1,32"
82+
string(72) "Control character error, possibly incorrectly encoded near location 1,27"
8383

8484
Error with UTF-8 escaped sequences:
8585
bool(false)
@@ -89,15 +89,15 @@ string(72) "Control character error, possibly incorrectly encoded near location
8989
Error in object with multiple UTF-8 keys:
9090
bool(false)
9191
int(3)
92-
string(72) "Control character error, possibly incorrectly encoded near location 1,32"
92+
string(72) "Control character error, possibly incorrectly encoded near location 1,22"
9393

9494
Error in array with UTF-8 strings:
9595
bool(false)
9696
int(3)
97-
string(72) "Control character error, possibly incorrectly encoded near location 1,30"
97+
string(72) "Control character error, possibly incorrectly encoded near location 1,18"
9898

9999
Error in nested object with UTF-8:
100100
bool(false)
101101
int(3)
102-
string(72) "Control character error, possibly incorrectly encoded near location 1,23"
102+
string(72) "Control character error, possibly incorrectly encoded near location 1,15"
103103

ext/json/tests/json_last_error_msg_error_location_005.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ string(72) "Control character error, possibly incorrectly encoded near location
6969
Error with UTF-16 in key:
7070
bool(false)
7171
int(3)
72-
string(72) "Control character error, possibly incorrectly encoded near location 1,24"
72+
string(71) "Control character error, possibly incorrectly encoded near location 1,9"
7373

7474
Error with multiple UTF-16 keys:
7575
bool(false)
7676
int(3)
77-
string(72) "Control character error, possibly incorrectly encoded near location 1,42"
77+
string(72) "Control character error, possibly incorrectly encoded near location 1,22"
7878

7979
Error with BMP characters:
8080
bool(false)
@@ -89,12 +89,12 @@ string(72) "Control character error, possibly incorrectly encoded near location
8989
Error in array with UTF-16:
9090
bool(false)
9191
int(3)
92-
string(72) "Control character error, possibly incorrectly encoded near location 1,22"
92+
string(72) "Control character error, possibly incorrectly encoded near location 1,12"
9393

9494
Error in nested structure with UTF-16:
9595
bool(false)
9696
int(3)
97-
string(72) "Control character error, possibly incorrectly encoded near location 1,28"
97+
string(72) "Control character error, possibly incorrectly encoded near location 1,18"
9898

9999
Error with UTF-16 and control chars:
100100
bool(false)

ext/json/tests/json_last_error_msg_error_location_008.phpt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,37 +83,37 @@ Testing error locations with various UTF-8 multi-byte character widths
8383
Error with 2-byte UTF-8 (Latin Extended):
8484
bool(false)
8585
int(3)
86-
string(72) "Control character error, possibly incorrectly encoded near location 1,11"
86+
string(72) "Control character error, possibly incorrectly encoded near location 1,10"
8787

8888
Error with 2-byte UTF-8 (Greek):
8989
bool(false)
9090
int(3)
91-
string(72) "Control character error, possibly incorrectly encoded near location 1,22"
91+
string(72) "Control character error, possibly incorrectly encoded near location 1,14"
9292

9393
Error with 2-byte UTF-8 (Cyrillic):
9494
bool(false)
9595
int(3)
96-
string(72) "Control character error, possibly incorrectly encoded near location 1,18"
96+
string(72) "Control character error, possibly incorrectly encoded near location 1,12"
9797

9898
Error with 3-byte UTF-8 (Chinese):
9999
bool(false)
100100
int(3)
101-
string(72) "Control character error, possibly incorrectly encoded near location 1,12"
101+
string(71) "Control character error, possibly incorrectly encoded near location 1,8"
102102

103103
Error with 3-byte UTF-8 (Japanese Hiragana):
104104
bool(false)
105105
int(3)
106-
string(72) "Control character error, possibly incorrectly encoded near location 1,18"
106+
string(72) "Control character error, possibly incorrectly encoded near location 1,10"
107107

108108
Error with 3-byte UTF-8 (Japanese Katakana):
109109
bool(false)
110110
int(3)
111-
string(72) "Control character error, possibly incorrectly encoded near location 1,18"
111+
string(72) "Control character error, possibly incorrectly encoded near location 1,10"
112112

113113
Error with 3-byte UTF-8 (Korean):
114114
bool(false)
115115
int(3)
116-
string(72) "Control character error, possibly incorrectly encoded near location 1,12"
116+
string(71) "Control character error, possibly incorrectly encoded near location 1,8"
117117

118118
Error with 4-byte UTF-8 (Emoji faces):
119119
bool(false)
@@ -148,35 +148,35 @@ string(71) "Control character error, possibly incorrectly encoded near location
148148
Error with UTF-8 key at start:
149149
bool(false)
150150
int(3)
151-
string(72) "Control character error, possibly incorrectly encoded near location 1,10"
151+
string(71) "Control character error, possibly incorrectly encoded near location 1,7"
152152

153153
Error with multiple UTF-8 keys:
154154
bool(false)
155155
int(3)
156-
string(72) "Control character error, possibly incorrectly encoded near location 1,51"
156+
string(72) "Control character error, possibly incorrectly encoded near location 1,35"
157157

158158
Error in array with mixed UTF-8:
159159
bool(false)
160160
int(3)
161-
string(72) "Control character error, possibly incorrectly encoded near location 1,30"
161+
string(72) "Control character error, possibly incorrectly encoded near location 1,25"
162162

163163
Error in nested structure with various UTF-8:
164164
bool(false)
165165
int(3)
166-
string(72) "Control character error, possibly incorrectly encoded near location 1,34"
166+
string(72) "Control character error, possibly incorrectly encoded near location 1,22"
167167

168168
Error with combining diacritical marks:
169169
bool(false)
170170
int(3)
171-
string(72) "Control character error, possibly incorrectly encoded near location 1,11"
171+
string(72) "Control character error, possibly incorrectly encoded near location 1,10"
172172

173173
Error with Hebrew:
174174
bool(false)
175175
int(3)
176-
string(72) "Control character error, possibly incorrectly encoded near location 1,14"
176+
string(72) "Control character error, possibly incorrectly encoded near location 1,10"
177177

178178
Error with Arabic with diacritics:
179179
bool(false)
180180
int(3)
181-
string(72) "Control character error, possibly incorrectly encoded near location 1,16"
181+
string(72) "Control character error, possibly incorrectly encoded near location 1,11"
182182

ext/json/tests/json_last_error_msg_error_location_009.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ string(72) "Control character error, possibly incorrectly encoded near location
101101
Error in deep UTF-8 structure:
102102
bool(false)
103103
int(3)
104-
string(72) "Control character error, possibly incorrectly encoded near location 1,22"
104+
string(72) "Control character error, possibly incorrectly encoded near location 1,16"
105105

106106
Valid deep structure within limit:
107107
bool(true)

0 commit comments

Comments
 (0)