Skip to content

Commit 3c6a1a3

Browse files
committed
Upgrade Lexbor
1 parent 78d185b commit 3c6a1a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+300588
-145266
lines changed

ext/lexbor/config.m4

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,10 @@ if test "$PHP_LEXBOR" != "no" || test "$PHP_LEXBOR_ENABLED" = "yes"; then
5959
$LEXBOR_DIR/dom/interfaces/processing_instruction.c
6060
$LEXBOR_DIR/dom/interfaces/shadow_root.c
6161
$LEXBOR_DIR/dom/interfaces/text.c
62-
$LEXBOR_DIR/encoding/big5.c
6362
$LEXBOR_DIR/encoding/decode.c
6463
$LEXBOR_DIR/encoding/encode.c
6564
$LEXBOR_DIR/encoding/encoding.c
66-
$LEXBOR_DIR/encoding/euc_kr.c
67-
$LEXBOR_DIR/encoding/gb18030.c
68-
$LEXBOR_DIR/encoding/iso_2022_jp_katakana.c
69-
$LEXBOR_DIR/encoding/jis0208.c
70-
$LEXBOR_DIR/encoding/jis0212.c
65+
$LEXBOR_DIR/encoding/multi.c
7166
$LEXBOR_DIR/encoding/range.c
7267
$LEXBOR_DIR/encoding/res.c
7368
$LEXBOR_DIR/encoding/single.c

ext/lexbor/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if (PHP_LEXBOR == "yes") {
1414
ADD_SOURCES("ext/lexbor/lexbor/html/tree", "active_formatting.c open_elements.c error.c","lexbor");
1515
ADD_SOURCES("ext/lexbor/lexbor/html/tree/insertion_mode", "after_after_body.c after_after_frameset.c after_body.c after_frameset.c after_head.c before_head.c before_html.c foreign_content.c in_body.c in_caption.c in_cell.c in_column_group.c in_frameset.c in_head.c in_head_noscript.c initial.c in_row.c in_select.c in_select_in_table.c in_table_body.c in_table.c in_table_text.c in_template.c text.c","lexbor");
1616
ADD_SOURCES("ext/lexbor/lexbor/html", "encoding.c interface.c parser.c token.c token_attr.c tokenizer.c tree.c","lexbor");
17-
ADD_SOURCES("ext/lexbor/lexbor/encoding", "big5.c decode.c encode.c encoding.c euc_kr.c gb18030.c iso_2022_jp_katakana.c jis0208.c jis0212.c range.c res.c single.c","lexbor");
17+
ADD_SOURCES("ext/lexbor/lexbor/encoding", "big5.c decode.c encode.c encoding.c multi.c range.c res.c single.c","lexbor");
1818
ADD_SOURCES("ext/lexbor/lexbor/html/interfaces", "anchor_element.c area_element.c audio_element.c base_element.c body_element.c br_element.c button_element.c canvas_element.c data_element.c data_list_element.c details_element.c dialog_element.c directory_element.c div_element.c d_list_element.c document.c element.c embed_element.c field_set_element.c font_element.c form_element.c frame_element.c frame_set_element.c head_element.c heading_element.c hr_element.c html_element.c iframe_element.c image_element.c input_element.c label_element.c legend_element.c li_element.c link_element.c map_element.c marquee_element.c media_element.c menu_element.c meta_element.c meter_element.c mod_element.c object_element.c o_list_element.c opt_group_element.c option_element.c output_element.c paragraph_element.c param_element.c picture_element.c pre_element.c progress_element.c quote_element.c script_element.c select_element.c slot_element.c source_element.c span_element.c style_element.c table_caption_element.c table_cell_element.c table_col_element.c table_element.c table_row_element.c table_section_element.c template_element.c text_area_element.c time_element.c title_element.c track_element.c u_list_element.c unknown_element.c video_element.c window.c","lexbor");
1919
ADD_SOURCES("ext/lexbor/lexbor/css", "state.c log.c parser.c css.c","lexbor");
2020
ADD_SOURCES("ext/lexbor/lexbor/css/selectors", "state.c selectors.c selector.c pseudo_state.c pseudo.c","lexbor");

ext/lexbor/lexbor/core/base.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2023 Alexander Borisov
2+
* Copyright (C) 2018-2024 Alexander Borisov
33
*
44
* Author: Alexander Borisov <borisov@lexbor.com>
55
*/
@@ -27,7 +27,7 @@ extern "C" {
2727
#include "lexbor/core/lexbor.h"
2828

2929
#define LEXBOR_VERSION_MAJOR 1
30-
#define LEXBOR_VERSION_MINOR 7
30+
#define LEXBOR_VERSION_MINOR 8
3131
#define LEXBOR_VERSION_PATCH 0
3232

3333
#define LEXBOR_VERSION_STRING LEXBOR_STRINGIZE(LEXBOR_VERSION_MAJOR) "." \

ext/lexbor/lexbor/core/conv.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,18 @@ lexbor_conv_data_to_uint(const lxb_char_t **data, size_t length)
305305
}
306306

307307
size_t
308-
lexbor_conv_dec_to_hex(uint32_t number, lxb_char_t *out, size_t length)
308+
lexbor_conv_dec_to_hex(uint32_t number, lxb_char_t *out, size_t length,
309+
bool upper)
309310
{
310311
lxb_char_t c;
311312
size_t len;
312313
uint32_t tmp;
314+
const lxb_char_t *map_str;
313315

314-
static const lxb_char_t map_str[] = "0123456789abcdef";
316+
static const lxb_char_t map_str_l[] = "0123456789abcdef";
317+
static const lxb_char_t map_str_u[] = "0123456789ABCDEF";
318+
319+
map_str = (upper) ? map_str_u : map_str_l;
315320

316321
if(number != 0) {
317322
tmp = number;

ext/lexbor/lexbor/core/conv.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ LXB_API unsigned
3737
lexbor_conv_data_to_uint(const lxb_char_t **data, size_t length);
3838

3939
LXB_API size_t
40-
lexbor_conv_dec_to_hex(uint32_t number, lxb_char_t *out, size_t length);
40+
lexbor_conv_dec_to_hex(uint32_t number, lxb_char_t *out, size_t length,
41+
bool upper);
4142

4243
lxb_inline long
4344
lexbor_conv_double_to_long(double number)

ext/lexbor/lexbor/core/mraw.c

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ lexbor_mraw_realloc_tail(lexbor_mraw_t *mraw, void *data, void *begin,
243243
size_t size, size_t begin_len, size_t new_size,
244244
bool *is_valid)
245245
{
246+
size_t length;
247+
uint8_t *tmp;
246248
lexbor_mem_chunk_t *chunk = mraw->mem->chunk;
247249

248250
if (chunk->size > (begin_len + new_size)) {
@@ -267,35 +269,26 @@ lexbor_mraw_realloc_tail(lexbor_mraw_t *mraw, void *data, void *begin,
267269
* If the tail is short then we increase the current data.
268270
*/
269271
if (begin_len == lexbor_mraw_meta_size()) {
270-
void *new_data;
271-
lexbor_mem_chunk_t new_chunk;
272-
273-
*is_valid = true;
274-
275-
lexbor_mem_chunk_init(mraw->mem, &new_chunk,
276-
new_size + lexbor_mraw_meta_size());
277-
if(new_chunk.data == NULL) {
278-
return NULL;
279-
}
280-
281-
lexbor_mraw_meta_set(new_chunk.data, &new_size);
282-
new_data = lexbor_mraw_data_begin(new_chunk.data);
283-
284-
if (size != 0) {
285-
memcpy(new_data, data, sizeof(uint8_t) * size);
286-
}
287-
288272
#if defined(LEXBOR_HAVE_ADDRESS_SANITIZER)
289273
ASAN_UNPOISON_MEMORY_REGION(chunk->data, chunk->size);
290274
#endif
275+
*is_valid = true;
291276

292-
lexbor_mem_chunk_destroy(mraw->mem, chunk, false);
277+
length = lexbor_mem_align(new_size + lexbor_mraw_meta_size()
278+
+ mraw->mem->chunk_min_size);
293279

294-
chunk->data = new_chunk.data;
295-
chunk->size = new_chunk.size;
280+
tmp = lexbor_realloc(chunk->data, length);
281+
if (tmp == NULL) {
282+
return NULL;
283+
}
284+
285+
chunk->data = tmp;
286+
chunk->size = length;
296287
chunk->length = new_size + lexbor_mraw_meta_size();
297288

298-
return new_data;
289+
lexbor_mraw_meta_set(tmp, &new_size);
290+
291+
return lexbor_mraw_data_begin(tmp);
299292
}
300293

301294
*is_valid = false;

ext/lexbor/lexbor/css/base.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2023 Alexander Borisov
2+
* Copyright (C) 2019-2025 Alexander Borisov
33
*
44
* Author: Alexander Borisov <borisov@lexbor.com>
55
*/
@@ -18,7 +18,7 @@ extern "C" {
1818

1919

2020
#define LXB_CSS_VERSION_MAJOR 1
21-
#define LXB_CSS_VERSION_MINOR 2
21+
#define LXB_CSS_VERSION_MINOR 3
2222
#define LXB_CSS_VERSION_PATCH 0
2323

2424
#define LXB_CSS_VERSION_STRING \

ext/lexbor/lexbor/css/parser.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ struct lxb_css_parser {
156156
lxb_css_syntax_token_type_t *types_end;
157157
lxb_css_syntax_token_type_t *types_pos;
158158

159-
lxb_css_syntax_tokenizer_chunk_f chunk_cb;
160-
void *chunk_ctx;
161-
162159
const lxb_char_t *pos;
163160
uintptr_t offset;
164161

ext/lexbor/lexbor/css/selectors/base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2021-2023 Alexander Borisov
2+
* Copyright (C) 2021-2024 Alexander Borisov
33
*
44
* Author: Alexander Borisov <borisov@lexbor.com>
55
*/

ext/lexbor/lexbor/css/syntax/base.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2023 Alexander Borisov
2+
* Copyright (C) 2018-2025 Alexander Borisov
33
*
44
* Author: Alexander Borisov <borisov@lexbor.com>
55
*/
@@ -17,7 +17,7 @@ extern "C" {
1717

1818

1919
#define LXB_CSS_SYNTAX_VERSION_MAJOR 1
20-
#define LXB_CSS_SYNTAX_VERSION_MINOR 1
20+
#define LXB_CSS_SYNTAX_VERSION_MINOR 3
2121
#define LXB_CSS_SYNTAX_VERSION_PATCH 0
2222

2323
#define LXB_CSS_SYNTAX_VERSION_STRING \

ext/lexbor/lexbor/css/syntax/parser.c

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2022 Alexander Borisov
2+
* Copyright (C) 2020-2025 Alexander Borisov
33
*
44
* Author: Alexander Borisov <borisov@lexbor.com>
55
*/
@@ -175,47 +175,6 @@ lxb_css_syntax_parser_consume(lxb_css_parser_t *parser)
175175
}
176176
}
177177

178-
lxb_status_t
179-
lxb_css_syntax_parser_tkz_cb(lxb_css_syntax_tokenizer_t *tkz,
180-
const lxb_char_t **data, const lxb_char_t **end,
181-
void *ctx)
182-
{
183-
size_t length, size;
184-
lxb_char_t *new_data;
185-
lxb_status_t status;
186-
lxb_css_parser_t *parser = ctx;
187-
188-
if (parser->pos == NULL) {
189-
return parser->chunk_cb(tkz, data, end, parser->chunk_ctx);
190-
}
191-
192-
length = (size_t) (*end - parser->pos);
193-
194-
if (SIZE_MAX - parser->str.length < length) {
195-
return LXB_STATUS_ERROR_OVERFLOW;
196-
}
197-
198-
if (parser->str.length + length >= parser->str_size) {
199-
size = parser->str.length + length + 1;
200-
201-
new_data = lexbor_realloc(parser->str.data, size);
202-
if (new_data == NULL) {
203-
return LXB_STATUS_ERROR_MEMORY_ALLOCATION;
204-
}
205-
206-
parser->str.data = new_data;
207-
parser->str_size = size;
208-
}
209-
210-
memcpy(parser->str.data + parser->str.length, parser->pos, length);
211-
212-
status = parser->chunk_cb(tkz, data, end, parser->chunk_ctx);
213-
parser->str.length += length;
214-
parser->pos = *data;
215-
216-
return status;
217-
}
218-
219178
lxb_css_syntax_rule_t *
220179
lxb_css_syntax_parser_list_rules_push(lxb_css_parser_t *parser,
221180
const lxb_css_syntax_token_t *token,

ext/lexbor/lexbor/css/syntax/parser.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2022 Alexander Borisov
2+
* Copyright (C) 2020-2025 Alexander Borisov
33
*
44
* Author: Alexander Borisov <borisov@lexbor.com>
55
*/
@@ -84,11 +84,6 @@ lxb_css_syntax_parser_pipe_push(lxb_css_parser_t *parser,
8484
const lxb_css_syntax_cb_pipe_t *pipe,
8585
void *ctx, lxb_css_syntax_token_type_t stop);
8686

87-
LXB_API lxb_status_t
88-
lxb_css_syntax_parser_tkz_cb(lxb_css_syntax_tokenizer_t *tkz,
89-
const lxb_char_t **data, const lxb_char_t **end,
90-
void *ctx);
91-
9287
LXB_API const lxb_css_syntax_token_t *
9388
lxb_css_syntax_parser_start_block(lxb_css_parser_t *parser,
9489
const lxb_css_syntax_token_t *token,

ext/lexbor/lexbor/css/syntax/res.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2019 Alexander Borisov
2+
* Copyright (C) 2018-2025 Alexander Borisov
33
*
44
* Author: Alexander Borisov <borisov@lexbor.com>
55
*/
@@ -26,20 +26,20 @@ static const lxb_char_t lxb_css_syntax_res_name_map[256] =
2626
0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01,
2727
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
2828
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
29-
0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
30-
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
31-
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
32-
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
33-
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
34-
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
35-
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
36-
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
37-
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
38-
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
29+
0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35+
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36+
0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
3937
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
38+
0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01,
4039
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
4140
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
42-
0x01, 0x01, 0x01, 0x01, 0x01, 0x01
41+
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01,
42+
0x01, 0x01, 0x01, 0x01, 0x01
4343
};
4444

4545
#endif /* LXB_CSS_SYNTAX_RES_NAME_MAP_ENABLED */

0 commit comments

Comments
 (0)