[php-src] master: Merge branch 'PHP-8.4' into PHP-8.5

From: Date: Sat, 21 Nov 2026 13:05:59 +0000
Subject: [php-src] master: Merge branch 'PHP-8.4' into PHP-8.5
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143995@lists.php.net to get a copy of this message
Author: David Carlier (devnexen) Date: 2026-11-21T13:04:00Z Commit: https://github.com/php/php-src/commit/0fcec7304054aab7afb2dfaa89f3516679c84774 Raw diff: https://github.com/php/php-src/commit/0fcec7304054aab7afb2dfaa89f3516679c84774.diff Merge branch 'PHP-8.4' into PHP-8.5 * PHP-8.4: ext/dom: querySelector() rejects a non-ASCII leading identifier. # Conflicts: # ext/lexbor/patches/0001-Expose-line-and-column-information-for-use-in-PHP.patch # ext/lexbor/patches/0002-Track-implied-added-nodes-for-options-use-in-PHP.patch # ext/lexbor/patches/0003-Patch-utilities-and-data-structure-to-be-able-to-gen.patch # ext/lexbor/patches/0004-Remove-unused-upper-case-tag-static-data.patch # ext/lexbor/patches/0005-Shrink-size-of-static-binary-search-tree.patch # ext/lexbor/patches/0006-Patch-out-unused-CSS-style-code.patch # ext/lexbor/patches/0009-CSS-Syntax-fixed-non-ASCII-ident-code-point-ranges.patch # ext/lexbor/patches/0010-iCSS-Syntax-fixed-U-FFFD-replacement-boundaries-for-.patch # ext/lexbor/patches/0011-CSS-Syntax-fixed-UTF-8-escapes-in-ident-sequences.patch # ext/lexbor/patches/0011-CSS-fixed-heap-buffer-overflow-in-lexbor-contains-pa.patch # ext/lexbor/patches/0012-CSS-Syntax-fixed-non-ASCII-ident-code-points.patch # ext/lexbor/patches/0012-Encoding-fixed-buffer-overflows-in-malformed-decode-.patch Changed paths: A ext/dom/tests/modern/css_selectors/gh25501.phpt A ext/lexbor/patches/0023-CSS-Syntax-fixed-non-ASCII-ident-code-point-ranges.patch A ext/lexbor/patches/0024-iCSS-Syntax-fixed-U-FFFD-replacement-boundaries-for-.patch A ext/lexbor/patches/0025-CSS-Syntax-fixed-UTF-8-escapes-in-ident-sequences.patch A ext/lexbor/patches/0026-CSS-Syntax-fixed-non-ASCII-ident-code-points.patch M ext/lexbor/lexbor/css/syntax/state.c M ext/lexbor/patches/0001-Expose-line-and-column-information-for-use-in-PHP.patch M ext/lexbor/patches/0002-Track-implied-added-nodes-for-options-use-in-PHP.patch M ext/lexbor/patches/0003-Patch-utilities-and-data-structure-to-be-able-to-gen.patch M ext/lexbor/patches/0004-Remove-unused-upper-case-tag-static-data.patch M ext/lexbor/patches/0005-Shrink-size-of-static-binary-search-tree.patch M ext/lexbor/patches/0006-Patch-out-unused-CSS-style-code.patch M ext/lexbor/patches/0007-URL-fixed-setters-for-empty-hosts.patch M ext/lexbor/patches/0008-URL-fixed-uninitialized-memory-in-the-path-buffer-gr.patch M ext/lexbor/patches/0009-Fix-parsing-for-URL-containing-empty-host-and-userin.patch M ext/lexbor/patches/0010-Percent-encode-the-caret-in-the-path.patch M ext/lexbor/patches/0011-CSS-fixed-heap-buffer-overflow-in-lexbor-contains-pa.patch M ext/lexbor/patches/0012-Encoding-fixed-buffer-overflows-in-malformed-decode-.patch M ext/lexbor/patches/0013-URL-fixed-tail-pointer-in-URLSearchParams-for-delimi.patch M ext/lexbor/patches/0014-URL-Fix-parsing-of-usernames-containing.patch M ext/lexbor/patches/0015-Unicode-fixed-uninitialized-memory-in-IDNA-buffer-gr.patch M ext/lexbor/patches/0016-URL-encode-opaque-path-spaces-before-query-and-fragm.patch M ext/lexbor/patches/0017-URL-Fix-lxb_url_serialize_fragment-without-a-query-4.patch M ext/lexbor/patches/0018-URL-expose-component-reset-functions.-415.patch M ext/lexbor/patches/0019-URL-Fix-parsing-of-query-and-fragment-after-a-dot-co.patch M ext/lexbor/patches/0020-URL-Keep-replacement-file-drive-paths-hierarchical-4.patch M ext/lexbor/patches/0021-URL-normalize-output-encoding-for-percent-encoding.patch M ext/lexbor/patches/0022-HTML-fixed-crash-use-after-free-and-leaks-on-allocat.patch Diff: diff --git a/ext/dom/tests/modern/css_selectors/gh25501.phpt b/ext/dom/tests/modern/css_selectors/gh25501.phpt new file mode 100644 index 000000000000..5b740bf9ba56 --- /dev/null +++ b/ext/dom/tests/modern/css_selectors/gh25501.phpt @@ -0,0 +1,53 @@ +--TEST-- +GH-25501 (querySelector() rejects a selector whose identifier starts with a non-ASCII character) +--CREDITS-- +phcorp +--EXTENSIONS-- +dom +--FILE-- +<?php + +$dom = Dom\HTMLDocument::createFromString( + '<p id="été">a</p><p class="élan">b</p><p class="café">c</p><p class="cafés">d</p>' + . '<p class="Über">e</p><p class="ͽx">f</p><p class="a×">g</p>', + LIBXML_NOERROR +); + +$selectors = [ + '#\e9 t\e9', + '#été', + 'p#été', + '[id=été]', + '.élan', + '.café', + '.cafés', + '.Über', + '.ͽx', + '.a×', + '#×', + '.÷x', +]; + +foreach ($selectors as $selector) { + echo $selector, ': '; + try { + var_dump($dom->querySelector($selector)?->textContent); + } catch (DOMException $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +?> +--EXPECT-- +#\e9 t\e9: string(1) "a" +#été: string(1) "a" +p#été: string(1) "a" +[id=été]: string(1) "a" +.élan: string(1) "b" +.café: string(1) "c" +.cafés: string(1) "d" +.Über: string(1) "e" +.ͽx: string(1) "f" +.a×: DOMException: Invalid selector (Selectors. Unexpected token: ×) +#×: DOMException: Invalid selector (Selectors. Unexpected token: #) +.÷x: DOMException: Invalid selector (Selectors. Unexpected token: ÷) diff --git a/ext/lexbor/lexbor/css/syntax/state.c b/ext/lexbor/lexbor/css/syntax/state.c index a93731e11235..5b694e9cdba6 100644 --- a/ext/lexbor/lexbor/css/syntax/state.c +++ b/ext/lexbor/lexbor/css/syntax/state.c @@ -67,21 +67,13 @@ } #define LXB_CSS_SYNTAX_UTF_8_UP_80_BLOCK(tkz, begin, data, end) \ + const lxb_char_t *_bad = data; \ lxb_codepoint_t cp = lxb_css_syntax_state_decode_utf_8_up_80(&data, \ end); \ \ if (cp == LXB_CSS_SYNTAX_ERROR_CODEPOINT) { \ - lxb_css_syntax_buffer_append_m(tkz, begin, data - begin); \ - /* U+FFFD REPLACEMENT CHARACTER */ \ - lxb_css_syntax_buffer_append_m(tkz, "\uFFFD", \ - lxb_css_syntax_replacement_length);\ - data += 1; \ - begin = data; \ - } \ - /* Surrogate U+D800 to U+DFFF. */ \ - else if (cp >= 0xD800 && cp <= 0xDFFF) { \ - lxb_css_syntax_buffer_append_m(tkz, begin, \ - (data - begin) - 3); \ + /* Flush the run before the ill-formed sequence, then U+FFFD. */ \ + lxb_css_syntax_buffer_append_m(tkz, begin, _bad - begin); \ /* U+FFFD REPLACEMENT CHARACTER */ \ lxb_css_syntax_buffer_append_m(tkz, "\uFFFD", \ lxb_css_syntax_replacement_length);\ @@ -157,44 +149,64 @@ lxb_css_syntax_state_valid_escape(const lxb_char_t *data, lxb_inline bool lxb_css_syntax_state_non_ascii(lxb_codepoint_t cp) { - /* - * Actually here the comparison should be to U+D7FF. - * But we capture surrogate pairs, they will be further converted to 0xFFFD. - */ - /* This code is generated by the file utils/lexbor/css/syntax/non_ascii.pl */ /* Begin */ - if (cp <= 0x2FEF) { - if (cp <= 0x1FFF) { - if (cp >= 0x00F8 && cp < 0x037D) { + if (cp <= 0x2040) { + if (cp <= 0x00F6) { + if (cp >= 0x00B7 && cp <= 0x00B7) { return true; } - else if (cp >= 0x037F) { - return true; + else if (cp >= 0x00C0) { + if (cp <= 0x00D6) { + return true; + } + else if (cp >= 0x00D8) { + return true; + } } } - else if (cp >= 0x2070) { - if (cp <= 0x218F) { - return true; + else if (cp >= 0x00F8) { + if (cp <= 0x1FFF) { + if (cp <= 0x037D) { + return true; + } + else if (cp >= 0x037F) { + return true; + } } - else if (cp >= 0x2C00) { - return true; + else if (cp >= 0x200C) { + if (cp <= 0x200D) { + return true; + } + else if (cp >= 0x203F) { + return true; + } } } } - else if (cp >= 0x3001) { - if (cp <= 0xFDCF) { - if (cp <= 0xDFFF) { + else if (cp >= 0x2070) { + if (cp <= 0xD7FF) { + if (cp <= 0x218F) { return true; } - else if (cp >= 0xF900) { - return true; + else if (cp >= 0x2C00) { + if (cp <= 0x2FEF) { + return true; + } + else if (cp >= 0x3001) { + return true; + } } } - else if (cp >= 0xFDF0) { + else if (cp >= 0xF900) { if (cp <= 0xFFFD) { - return true; + if (cp <= 0xFDCF) { + return true; + } + else if (cp >= 0xFDF0) { + return true; + } } else if (cp >= 0x10000) { if (cp <= 0x10FFFF) { @@ -205,7 +217,7 @@ lxb_css_syntax_state_non_ascii(lxb_codepoint_t cp) } /* End */ - return cp == 0x200C || cp == 0x200D || cp == 0x203F || cp == 0x2040; + return false; } lxb_inline bool @@ -565,14 +577,6 @@ lxb_css_syntax_state_string(lxb_css_syntax_tokenizer_t *tkz, lxb_css_syntax_toke cp = lxb_css_syntax_state_decode_utf_8_up_80(&data, end); if (cp == LXB_CSS_SYNTAX_ERROR_CODEPOINT) { - /* U+FFFD REPLACEMENT CHARACTER */ - lxb_css_syntax_buffer_append_m(tkz, "\uFFFD", - lxb_css_syntax_replacement_length); - data += 1; - begin = data; - } - /* Surrogate U+D800 to U+DFFF. */ - else if (cp >= 0xD800 && cp <= 0xDFFF) { /* U+FFFD REPLACEMENT CHARACTER */ lxb_css_syntax_buffer_append_m(tkz, "\uFFFD", lxb_css_syntax_replacement_length); @@ -629,6 +633,17 @@ lxb_css_syntax_state_hash(lxb_css_syntax_tokenizer_t *tkz, return lxb_css_syntax_state_delim_set(token, data - 1, '#'); } + if (*data >= 0x80) { + begin = data; + + if (lxb_css_syntax_state_start_ident_utf_8_80(&data, end)) { + data = begin; + goto hash; + } + + return lxb_css_syntax_state_delim_set(token, begin - 1, '#'); + } + if (lxb_css_syntax_res_name_map[*data] == 0x00) { if (*data == 0x00) { goto hash; @@ -1202,6 +1217,7 @@ lxb_css_syntax_state_consume_ident(lxb_css_syntax_tokenizer_t *tkz, else { LXB_CSS_SYNTAX_UTF_8_UP_80_BLOCK(tkz, begin, data, end) else if (!lxb_css_syntax_state_non_ascii(cp)) { + data = _bad; break; } } @@ -1630,7 +1646,13 @@ lxb_css_syntax_state_escaped(lxb_css_syntax_tokenizer_t *tkz, if (lexbor_str_res_map_hex[*data] == 0xFF) { if (count == 0) { - cp = (lxb_codepoint_t) *data++; + if (*data < 0x80) { + cp = (lxb_codepoint_t) *data++; + } + else { + cp = lxb_css_syntax_state_decode_utf_8_up_80(&data, end); + } + goto done; } @@ -1770,98 +1792,61 @@ static lxb_codepoint_t lxb_css_syntax_state_decode_utf_8_up_80(const lxb_char_t **data, const lxb_char_t *end) { - lxb_char_t ch; + lxb_char_t ch, lower, upper; + unsigned needed; const lxb_char_t *p; lxb_codepoint_t cp; + /* + * WHATWG UTF-8 decoder: https://encoding.spec.whatwg.org/#utf-8-decoder + */ + p = *data; - ch = *p; + ch = *p++; if (ch <= 0xDF) { - if (ch < 0xC2 || p + 1 >= end) { + if (ch < 0xC2) { + *data = p; return LXB_CSS_SYNTAX_ERROR_CODEPOINT; } + needed = 1; + lower = 0x80; + upper = 0xBF; cp = ch & 0x1F; - - if (p[1] < 0x80 || p[1] > 0xBF) { - return LXB_CSS_SYNTAX_ERROR_CODEPOINT; - } - - cp = (cp << 6) | (p[1] & 0x3F); - - *data += 2; } - else if (ch < 0xF0) { + else if (ch <= 0xEF) { + needed = 2; + lower = (ch == 0xE0) ? 0xA0 : 0x80; + upper = (ch == 0xED) ? 0x9F : 0xBF; cp = ch & 0x0F; - - if (p + 2 >= end) { - return LXB_CSS_SYNTAX_ERROR_CODEPOINT; - } - - if (ch == 0xE0) { - if (p[1] < 0xA0 || p[1] > 0xBF) { - return LXB_CSS_SYNTAX_ERROR_CODEPOINT; - } - } - - /* - * We returning surrogate pair! - */ -/* - else if (ch == 0xED) { - if (p[1] < 0x80 || p[1] > 0x9F) { - return LXB_CSS_SYNTAX_ERROR_CODEPOINT; - } - } - */ - else if (p[1] < 0x80 || p[1] > 0xBF) { - return LXB_CSS_SYNTAX_ERROR_CODEPOINT; - } - - if (p[2] < 0x80 || p[2] > 0xBF) { - return LXB_CSS_SYNTAX_ERROR_CODEPOINT; - } - - cp = (cp << 6) | (p[1] & 0x3F); - cp = (cp << 6) | (p[2] & 0x3F); - - *data += 3; } - else if (ch < 0xF5) { + else if (ch <= 0xF4) { + needed = 3; + lower = (ch == 0xF0) ? 0x90 : 0x80; + upper = (ch == 0xF4) ? 0x8F : 0xBF; cp = ch & 0x07; + } + else { + /* 0xF5..0xFF: an invalid lead byte. */ + *data = p; + return LXB_CSS_SYNTAX_ERROR_CODEPOINT; + } - if (p + 3 >= end) { - return LXB_CSS_SYNTAX_ERROR_CODEPOINT; - } - - if (ch == 0xF0) { - if (p[1] < 0x90 || p[1] > 0xBF) { - return LXB_CSS_SYNTAX_ERROR_CODEPOINT; - } - } - else if (ch == 0xF4) { - if (p[1] < 0x80 || p[1] > 0x8F) { - return LXB_CSS_SYNTAX_ERROR_CODEPOINT; - } - } - else if (p[1] < 0x80 || p[1] > 0xBF) { - return LXB_CSS_SYNTAX_ERROR_CODEPOINT; - } - - if ((p[2] < 0x80 || p[2] > 0xBF) || (p[3] < 0x80 || p[3] > 0xBF)) { + do { + if (p >= end || *p < lower || *p > upper) { + *data = p; return LXB_CSS_SYNTAX_ERROR_CODEPOINT; } - cp = (cp << 6) | (p[1] & 0x3F); - cp = (cp << 6) | (p[2] & 0x3F); - cp = (cp << 6) | (p[3] & 0x3F); + cp = (cp << 6) | (*p++ & 0x3F); - *data += 4; - } - else { - return LXB_CSS_SYNTAX_ERROR_CODEPOINT; + lower = 0x80; + upper = 0xBF; } + while (--needed != 0); + + *data = p; return cp; } diff --git a/ext/lexbor/patches/0001-Expose-line-and-column-information-for-use-in-PHP.patch b/ext/lexbor/patches/0001-Expose-line-and-column-information-for-use-in-PHP.patch index 9cb75078bd22..8a5a13166a78 100644 --- a/ext/lexbor/patches/0001-Expose-line-and-column-information-for-use-in-PHP.patch +++ b/ext/lexbor/patches/0001-Expose-line-and-column-information-for-use-in-PHP.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 26 Aug 2023 15:08:59 +0200 -Subject: [PATCH 01/22] Expose line and column information for use in PHP +Subject: [PATCH 01/26] Expose line and column information for use in PHP --- source/lexbor/dom/interfaces/node.h | 2 ++ diff --git a/ext/lexbor/patches/0002-Track-implied-added-nodes-for-options-use-in-PHP.patch b/ext/lexbor/patches/0002-Track-implied-added-nodes-for-options-use-in-PHP.patch index 2bf5350d5c42..c6f567e9954d 100644 --- a/ext/lexbor/patches/0002-Track-implied-added-nodes-for-options-use-in-PHP.patch +++ b/ext/lexbor/patches/0002-Track-implied-added-nodes-for-options-use-in-PHP.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Mon, 14 Aug 2023 20:18:51 +0200 -Subject: [PATCH 02/22] Track implied added nodes for options use in PHP +Subject: [PATCH 02/26] Track implied added nodes for options use in PHP --- source/lexbor/html/tree.h | 3 +++ diff --git a/ext/lexbor/patches/0003-Patch-utilities-and-data-structure-to-be-able-to-gen.patch b/ext/lexbor/patches/0003-Patch-utilities-and-data-structure-to-be-able-to-gen.patch index 2f13684510e1..e2bddc62b70f 100644 --- a/ext/lexbor/patches/0003-Patch-utilities-and-data-structure-to-be-able-to-gen.patch +++ b/ext/lexbor/patches/0003-Patch-utilities-and-data-structure-to-be-able-to-gen.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Thu, 24 Aug 2023 22:57:48 +0200 -Subject: [PATCH 03/22] Patch utilities and data structure to be able to +Subject: [PATCH 03/26] Patch utilities and data structure to be able to generate smaller lookup tables Changed the generation script to check if everything fits in 32-bits. diff --git a/ext/lexbor/patches/0004-Remove-unused-upper-case-tag-static-data.patch b/ext/lexbor/patches/0004-Remove-unused-upper-case-tag-static-data.patch index c5f7ef521671..2a4dcdc4e4d9 100644 --- a/ext/lexbor/patches/0004-Remove-unused-upper-case-tag-static-data.patch +++ b/ext/lexbor/patches/0004-Remove-unused-upper-case-tag-static-data.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Wed, 29 Nov 2023 21:26:47 +0100 -Subject: [PATCH 04/22] Remove unused upper case tag static data +Subject: [PATCH 04/26] Remove unused upper case tag static data --- source/lexbor/tag/res.h | 2 ++ diff --git a/ext/lexbor/patches/0005-Shrink-size-of-static-binary-search-tree.patch b/ext/lexbor/patches/0005-Shrink-size-of-static-binary-search-tree.patch index 4d158dbc771d..5ed745307ad6 100644 --- a/ext/lexbor/patches/0005-Shrink-size-of-static-binary-search-tree.patch +++ b/ext/lexbor/patches/0005-Shrink-size-of-static-binary-search-tree.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Wed, 29 Nov 2023 21:29:31 +0100 -Subject: [PATCH 05/22] Shrink size of static binary search tree +Subject: [PATCH 05/26] Shrink size of static binary search tree This also makes it more efficient on the data cache. --- diff --git a/ext/lexbor/patches/0006-Patch-out-unused-CSS-style-code.patch b/ext/lexbor/patches/0006-Patch-out-unused-CSS-style-code.patch index b95a36de6f45..58e64a0441cd 100644 --- a/ext/lexbor/patches/0006-Patch-out-unused-CSS-style-code.patch +++ b/ext/lexbor/patches/0006-Patch-out-unused-CSS-style-code.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sun, 7 Jan 2024 21:59:28 +0100 -Subject: [PATCH 06/22] Patch out unused CSS style code +Subject: [PATCH 06/26] Patch out unused CSS style code --- source/lexbor/css/rule.h | 2 ++ diff --git a/ext/lexbor/patches/0007-URL-fixed-setters-for-empty-hosts.patch b/ext/lexbor/patches/0007-URL-fixed-setters-for-empty-hosts.patch index 7dc2f925b6d3..ea8a498ef59d 100644 --- a/ext/lexbor/patches/0007-URL-fixed-setters-for-empty-hosts.patch +++ b/ext/lexbor/patches/0007-URL-fixed-setters-for-empty-hosts.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Alexander Borisov <lex.borisov@gmail.com> Date: Fri, 26 Jun 2026 18:55:56 +0300 -Subject: [PATCH 07/22] URL: fixed setters for empty hosts. +Subject: [PATCH 07/26] URL: fixed setters for empty hosts. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit diff --git a/ext/lexbor/patches/0008-URL-fixed-uninitialized-memory-in-the-path-buffer-gr.patch b/ext/lexbor/patches/0008-URL-fixed-uninitialized-memory-in-the-path-buffer-gr.patch index fc24314c7431..745e49983dac 100644 --- a/ext/lexbor/patches/0008-URL-fixed-uninitialized-memory-in-the-path-buffer-gr.patch +++ b/ext/lexbor/patches/0008-URL-fixed-uninitialized-memory-in-the-path-buffer-gr.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Alexander Borisov <lex.borisov@gmail.com> Date: Fri, 5 Jun 2026 22:13:32 +0300 -Subject: [PATCH 08/22] URL: fixed uninitialized memory in the path buffer +Subject: [PATCH 08/26] URL: fixed uninitialized memory in the path buffer growth. When a path was long enough to outgrow the on-stack buffer, the first diff --git a/ext/lexbor/patches/0009-Fix-parsing-for-URL-containing-empty-host-and-userin.patch b/ext/lexbor/patches/0009-Fix-parsing-for-URL-containing-empty-host-and-userin.patch index d45d0b758869..3a9b367139e5 100644 --- a/ext/lexbor/patches/0009-Fix-parsing-for-URL-containing-empty-host-and-userin.patch +++ b/ext/lexbor/patches/0009-Fix-parsing-for-URL-containing-empty-host-and-userin.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= <kocsismate@woohoolabs.com> Date: Thu, 9 Jul 2026 21:51:05 +0200 -Subject: [PATCH 09/22] Fix parsing for URL containing empty host and userinfo +Subject: [PATCH 09/26] Fix parsing for URL containing empty host and userinfo The returned error code (LXB_URL_ERROR_TYPE_INVALID_CREDENTIALS) apparently contradicts the specification: diff --git a/ext/lexbor/patches/0010-Percent-encode-the-caret-in-the-path.patch b/ext/lexbor/patches/0010-Percent-encode-the-caret-in-the-path.patch index 7ff8d6f9582c..bfd69c9a3f9c 100644 --- a/ext/lexbor/patches/0010-Percent-encode-the-caret-in-the-path.patch +++ b/ext/lexbor/patches/0010-Percent-encode-the-caret-in-the-path.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= <kocsismate@woohoolabs.com> Date: Fri, 10 Jul 2026 22:31:16 +0200 -Subject: [PATCH 10/22] Percent-encode the caret in the path +Subject: [PATCH 10/26] Percent-encode the caret in the path The caret (^) is part of the path percent-encode set: diff --git a/ext/lexbor/patches/0011-CSS-fixed-heap-buffer-overflow-in-lexbor-contains-pa.patch b/ext/lexbor/patches/0011-CSS-fixed-heap-buffer-overflow-in-lexbor-contains-pa.patch index 975f400b98f0..8d32202c968b 100644 --- a/ext/lexbor/patches/0011-CSS-fixed-heap-buffer-overflow-in-lexbor-contains-pa.patch +++ b/ext/lexbor/patches/0011-CSS-fixed-heap-buffer-overflow-in-lexbor-contains-pa.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Alexander Borisov <lex.borisov@gmail.com> Date: Fri, 5 Jun 2026 22:34:23 +0300 -Subject: [PATCH 11/22] CSS: fixed heap buffer overflow in :lexbor-contains() +Subject: [PATCH 11/26] CSS: fixed heap buffer overflow in :lexbor-contains() parsing. The contains string buffer was allocated by the size of the string diff --git a/ext/lexbor/patches/0012-Encoding-fixed-buffer-overflows-in-malformed-decode-.patch b/ext/lexbor/patches/0012-Encoding-fixed-buffer-overflows-in-malformed-decode-.patch index bc243bc250e6..b7c87caf18fc 100644 --- a/ext/lexbor/patches/0012-Encoding-fixed-buffer-overflows-in-malformed-decode-.patch +++ b/ext/lexbor/patches/0012-Encoding-fixed-buffer-overflows-in-malformed-decode-.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Alexander Borisov <lex.borisov@gmail.com> Date: Wed, 10 Jun 2026 19:50:10 +0300 -Subject: [PATCH 12/22] Encoding: fixed buffer overflows in malformed decode +Subject: [PATCH 12/26] Encoding: fixed buffer overflows in malformed decode replay. Fixed out-of-bounds writes in buffering decoders when replacement output diff --git a/ext/lexbor/patches/0013-URL-fixed-tail-pointer-in-URLSearchParams-for-delimi.patch b/ext/lexbor/patches/0013-URL-fixed-tail-pointer-in-URLSearchParams-for-delimi.patch index 38a36be323ec..de4d33a4ea64 100644 --- a/ext/lexbor/patches/0013-URL-fixed-tail-pointer-in-URLSearchParams-for-delimi.patch +++ b/ext/lexbor/patches/0013-URL-fixed-tail-pointer-in-URLSearchParams-for-delimi.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Alexander Borisov <lex.borisov@gmail.com> Date: Fri, 5 Jun 2026 21:46:26 +0300 -Subject: [PATCH 13/22] URL: fixed tail pointer in URLSearchParams for +Subject: [PATCH 13/26] URL: fixed tail pointer in URLSearchParams for delimiter-free query. When a query had a single token without '=' or '&' (e.g. "?abc"), the diff --git a/ext/lexbor/patches/0014-URL-Fix-parsing-of-usernames-containing.patch b/ext/lexbor/patches/0014-URL-Fix-parsing-of-usernames-containing.patch index 9e1cc2fd4425..aa557cb10f19 100644 --- a/ext/lexbor/patches/0014-URL-Fix-parsing-of-usernames-containing.patch +++ b/ext/lexbor/patches/0014-URL-Fix-parsing-of-usernames-containing.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= <tim@bastelstu.be> Date: Fri, 31 Jul 2026 20:56:18 +0200 -Subject: [PATCH 14/22] URL: Fix parsing of usernames containing @ +Subject: [PATCH 14/26] URL: Fix parsing of usernames containing @ Fixes lexbor/lexbor#399. --- diff --git a/ext/lexbor/patches/0015-Unicode-fixed-uninitialized-memory-in-IDNA-buffer-gr.patch b/ext/lexbor/patches/0015-Unicode-fixed-uninitialized-memory-in-IDNA-buffer-gr.patch index a50bd4d5a253..313d0cda4363 100644 --- a/ext/lexbor/patches/0015-Unicode-fixed-uninitialized-memory-in-IDNA-buffer-gr.patch +++ b/ext/lexbor/patches/0015-Unicode-fixed-uninitialized-memory-in-IDNA-buffer-gr.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Alexander Borisov <lex.borisov@gmail.com> Date: Mon, 7 Sep 2026 22:11:39 +0300 -Subject: [PATCH 15/22] Unicode: fixed uninitialized memory in IDNA buffer +Subject: [PATCH 15/26] Unicode: fixed uninitialized memory in IDNA buffer growth. When an IDNA buffer outgrew the stack allocation, the move to the heap diff --git a/ext/lexbor/patches/0016-URL-encode-opaque-path-spaces-before-query-and-fragm.patch b/ext/lexbor/patches/0016-URL-encode-opaque-path-spaces-before-query-and-fragm.patch index bcf14d139879..e6bc91549d4f 100644 --- a/ext/lexbor/patches/0016-URL-encode-opaque-path-spaces-before-query-and-fragm.patch +++ b/ext/lexbor/patches/0016-URL-encode-opaque-path-spaces-before-query-and-fragm.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= <kocsismate@woohoolabs.com> Date: Fri, 11 Sep 2026 21:58:45 +0200 -Subject: [PATCH 16/22] URL: encode opaque path spaces before query and +Subject: [PATCH 16/26] URL: encode opaque path spaces before query and fragment. (#405) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 diff --git a/ext/lexbor/patches/0017-URL-Fix-lxb_url_serialize_fragment-without-a-query-4.patch b/ext/lexbor/patches/0017-URL-Fix-lxb_url_serialize_fragment-without-a-query-4.patch index b645c0024a8f..1fa964f2120d 100644 --- a/ext/lexbor/patches/0017-URL-Fix-lxb_url_serialize_fragment-without-a-query-4.patch +++ b/ext/lexbor/patches/0017-URL-Fix-lxb_url_serialize_fragment-without-a-query-4.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= <tim@tideways-gmbh.com> Date: Fri, 11 Sep 2026 22:45:33 +0200 -Subject: [PATCH 17/22] URL: Fix lxb_url_serialize_fragment() without a query +Subject: [PATCH 17/26] URL: Fix lxb_url_serialize_fragment() without a query (#410) The lxb_url_serialize_fragment() function checked if the query contained data diff --git a/ext/lexbor/patches/0018-URL-expose-component-reset-functions.-415.patch b/ext/lexbor/patches/0018-URL-expose-component-reset-functions.-415.patch index ed27f5fe6c7d..1a972b600bce 100644 --- a/ext/lexbor/patches/0018-URL-expose-component-reset-functions.-415.patch +++ b/ext/lexbor/patches/0018-URL-expose-component-reset-functions.-415.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= <kocsismate@woohoolabs.com> Date: Tue, 22 Sep 2026 22:20:28 +0200 -Subject: [PATCH 18/22] URL: expose component reset functions. (#415) +Subject: [PATCH 18/26] URL: expose component reset functions. (#415) * URL: expose component reset functions. diff --git a/ext/lexbor/patches/0019-URL-Fix-parsing-of-query-and-fragment-after-a-dot-co.patch b/ext/lexbor/patches/0019-URL-Fix-parsing-of-query-and-fragment-after-a-dot-co.patch index c1cd41a6b755..9f16a867ec87 100644 --- a/ext/lexbor/patches/0019-URL-Fix-parsing-of-query-and-fragment-after-a-dot-co.patch +++ b/ext/lexbor/patches/0019-URL-Fix-parsing-of-query-and-fragment-after-a-dot-co.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= <tim@tideways-gmbh.com> Date: Sat, 26 Sep 2026 18:41:05 +0200 -Subject: [PATCH 19/22] URL: Fix parsing of query and fragment after a +Subject: [PATCH 19/26] URL: Fix parsing of query and fragment after a dot-component in path (#411) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 diff --git a/ext/lexbor/patches/0020-URL-Keep-replacement-file-drive-paths-hierarchical-4.patch b/ext/lexbor/patches/0020-URL-Keep-replacement-file-drive-paths-hierarchical-4.patch index 22d897de5c6f..f4a861c022a1 100644 --- a/ext/lexbor/patches/0020-URL-Keep-replacement-file-drive-paths-hierarchical-4.patch +++ b/ext/lexbor/patches/0020-URL-Keep-replacement-file-drive-paths-hierarchical-4.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= <kocsismate@woohoolabs.com> Date: Mon, 21 Sep 2026 20:01:43 +0200 -Subject: [PATCH 20/22] URL: Keep replacement file drive paths hierarchical +Subject: [PATCH 20/26] URL: Keep replacement file drive paths hierarchical (#423) WHATWG file state (https://url.spec.whatwg.org/#file-state) step 4.4.3.2 resets the path to an empty list. Do not mark it opaque, as that makes subsequent pathname updates silently do nothing. diff --git a/ext/lexbor/patches/0021-URL-normalize-output-encoding-for-percent-encoding.patch b/ext/lexbor/patches/0021-URL-normalize-output-encoding-for-percent-encoding.patch index c1fe49461a28..2e2f4331a518 100644 --- a/ext/lexbor/patches/0021-URL-normalize-output-encoding-for-percent-encoding.patch +++ b/ext/lexbor/patches/0021-URL-normalize-output-encoding-for-percent-encoding.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Alexander Borisov <lex.borisov@gmail.com> Date: Thu, 24 Sep 2026 15:05:51 +0300 -Subject: [PATCH 21/22] URL: normalize output encoding for percent-encoding. +Subject: [PATCH 21/26] URL: normalize output encoding for percent-encoding. --- source/lexbor/url/url.c | 34 +++++++++++++++++++++++++--------- diff --git a/ext/lexbor/patches/0022-HTML-fixed-crash-use-after-free-and-leaks-on-allocat.patch b/ext/lexbor/patches/0022-HTML-fixed-crash-use-after-free-and-leaks-on-allocat.patch index 14f242091a51..46c06e288402 100644 --- a/ext/lexbor/patches/0022-HTML-fixed-crash-use-after-free-and-leaks-on-allocat.patch +++ b/ext/lexbor/patches/0022-HTML-fixed-crash-use-after-free-and-leaks-on-allocat.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: sjanel <67502353+sjanel@users.noreply.github.com> Date: Wed, 11 Nov 2026 20:26:42 +0100 -Subject: [PATCH 22/22] HTML: fixed crash, use-after-free and leaks on +Subject: [PATCH 22/26] HTML: fixed crash, use-after-free and leaks on allocation failure in document create and parse (#448) HTML: fixed crash, use-after-free and leaks on allocation failure. diff --git a/ext/lexbor/patches/0023-CSS-Syntax-fixed-non-ASCII-ident-code-point-ranges.patch b/ext/lexbor/patches/0023-CSS-Syntax-fixed-non-ASCII-ident-code-point-ranges.patch new file mode 100644 index 000000000000..280e7839582c --- /dev/null +++ b/ext/lexbor/patches/0023-CSS-Syntax-fixed-non-ASCII-ident-code-point-ranges.patch @@ -0,0 +1,78 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Alexander Borisov <lex.borisov@gmail.com> +Date: Sat, 20 Jun 2026 15:39:44 +0400 +Subject: [PATCH 23/26] CSS::Syntax: fixed non-ASCII ident code point ranges. + +By specification https://drafts.csswg.org/css-syntax/#non-ascii-ident-code-point. + +Per report from Jon Surrell (@sirreal). + +This relates to #382 issue on GitHub. +--- + source/lexbor/css/syntax/state.c | 41 ++++++++++++++++++++++---------- + 1 file changed, 28 insertions(+), 13 deletions(-) + +diff --git a/source/lexbor/css/syntax/state.c b/source/lexbor/css/syntax/state.c +index a93731e..a011c5a 100644 +--- a/source/lexbor/css/syntax/state.c ++++ b/source/lexbor/css/syntax/state.c +@@ -165,31 +165,46 @@ lxb_css_syntax_state_non_ascii(lxb_codepoint_t cp) + /* This code is generated by the file utils/lexbor/css/syntax/non_ascii.pl */ + + /* Begin */ +- if (cp <= 0x2FEF) { +- if (cp <= 0x1FFF) { +- if (cp >= 0x00F8 && cp < 0x037D) { ++ if (cp <= 0x218F) { ++ if (cp <= 0x00F6) { ++ if (cp >= 0x00B7 && cp <= 0x00B7) { + return true; + } +- else if (cp >= 0x037F) { +- return true; ++ else if (cp >= 0x00C0) { ++ if (cp <= 0x00D6) { ++ return true; ++ } ++ else if (cp >= 0x00D8) { ++ return true; ++ } + } + } +- else if (cp >= 0x2070) { +- if (cp <= 0x218F) { ++ else if (cp >= 0x00F8) { ++ if (cp <= 0x037D) { + return true; + } +- else if (cp >= 0x2C00) { +- return true; ++ else if (cp >= 0x037F) { ++ if (cp <= 0x1FFF) { ++ return true; ++ } ++ else if (cp >= 0x2070) { ++ return true; ++ } + } + } + } +- else if (cp >= 0x3001) { ++ else if (cp >= 0x2C00) { + if (cp <= 0xFDCF) { +- if (cp <= 0xDFFF) { ++ if (cp <= 0x2FEF) { + return true; + } +- else if (cp >= 0xF900) { +- return true; ++ else if (cp >= 0x3001) { ++ if (cp <= 0xDFFF) { ++ return true; ++ } ++ else if (cp >= 0xF900) { ++ return true; ++ } + } + } + else if (cp >= 0xFDF0) { diff --git a/ext/lexbor/patches/0024-iCSS-Syntax-fixed-U-FFFD-replacement-boundaries-for-.patch b/ext/lexbor/patches/0024-iCSS-Syntax-fixed-U-FFFD-replacement-boundaries-for-.patch new file mode 100644 index 000000000000..dbafbc7b0cc9 --- /dev/null +++ b/ext/lexbor/patches/0024-iCSS-Syntax-fixed-U-FFFD-replacement-boundaries-for-.patch @@ -0,0 +1,201 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Alexander Borisov <lex.borisov@gmail.com> +Date: Wed, 8 Jul 2026 20:10:47 +0300 +Subject: [PATCH 24/26] iCSS::Syntax: fixed U+FFFD replacement boundaries for + UTF-8. + +The tokenizer replaced ill-formed UTF-8 with U+FFFD at boundaries that do +not match the specification and browsers. A truncated sequence with valid +continuation bytes (E2 8C) produced two U+FFFD instead of one, and a UTF-8 +encoded surrogate (ED A0 80) produced one U+FFFD instead of three. + +By specification, each maximal subpart of an ill-formed subsequence must +be replaced with a single U+FFFD: +https://drafts.csswg.org/css-syntax/#input-byte-stream +https://encoding.spec.whatwg.org/#utf-8-decoder + +Per report from Jon Surrell (@sirreal). + +This closes #390 issue on GitHub. +--- + source/lexbor/css/syntax/state.c | 129 +++++++++---------------------- + 1 file changed, 38 insertions(+), 91 deletions(-) + +diff --git a/source/lexbor/css/syntax/state.c b/source/lexbor/css/syntax/state.c +index a011c5a..abcf930 100644 +--- a/source/lexbor/css/syntax/state.c ++++ b/source/lexbor/css/syntax/state.c +@@ -67,21 +67,13 @@ + } + + #define LXB_CSS_SYNTAX_UTF_8_UP_80_BLOCK(tkz, begin, data, end) \ ++ const lxb_char_t *_bad = data; \ + lxb_codepoint_t cp = lxb_css_syntax_state_decode_utf_8_up_80(&data, \ + end); \ + \ + if (cp == LXB_CSS_SYNTAX_ERROR_CODEPOINT) { \ +- lxb_css_syntax_buffer_append_m(tkz, begin, data - begin); \ +- /* U+FFFD REPLACEMENT CHARACTER */ \ +- lxb_css_syntax_buffer_append_m(tkz, "\uFFFD", \ +- lxb_css_syntax_replacement_length);\ +- data += 1; \ +- begin = data; \ +- } \ +- /* Surrogate U+D800 to U+DFFF. */ \ +- else if (cp >= 0xD800 && cp <= 0xDFFF) { \ +- lxb_css_syntax_buffer_append_m(tkz, begin, \ +- (data - begin) - 3); \ ++ /* Flush the run before the ill-formed sequence, then U+FFFD. */ \ ++ lxb_css_syntax_buffer_append_m(tkz, begin, _bad - begin); \ + /* U+FFFD REPLACEMENT CHARACTER */ \ + lxb_css_syntax_buffer_append_m(tkz, "\uFFFD", \ + lxb_css_syntax_replacement_length);\ +@@ -580,14 +572,6 @@ lxb_css_syntax_state_string(lxb_css_syntax_tokenizer_t *tkz, lxb_css_syntax_toke + cp = lxb_css_syntax_state_decode_utf_8_up_80(&data, end); + + if (cp == LXB_CSS_SYNTAX_ERROR_CODEPOINT) { +- /* U+FFFD REPLACEMENT CHARACTER */ +- lxb_css_syntax_buffer_append_m(tkz, "\uFFFD", +- lxb_css_syntax_replacement_length); +- data += 1; +- begin = data; +- } +- /* Surrogate U+D800 to U+DFFF. */ +- else if (cp >= 0xD800 && cp <= 0xDFFF) { + /* U+FFFD REPLACEMENT CHARACTER */ + lxb_css_syntax_buffer_append_m(tkz, "\uFFFD", + lxb_css_syntax_replacement_length); +@@ -1785,98 +1769,61 @@ static lxb_codepoint_t + lxb_css_syntax_state_decode_utf_8_up_80(const lxb_char_t **data, + const lxb_char_t *end) + { +- lxb_char_t ch; ++ lxb_char_t ch, lower, upper; ++ unsigned needed; + const lxb_char_t *p; + lxb_codepoint_t cp; + ++ /* ++ * WHATWG UTF-8 decoder: https://encoding.spec.whatwg.org/#utf-8-decoder ++ */ ++ + p = *data; +- ch = *p; ++ ch = *p++; + + if (ch <= 0xDF) { +- if (ch < 0xC2 || p + 1 >= end) { ++ if (ch < 0xC2) { ++ *data = p; + return LXB_CSS_SYNTAX_ERROR_CODEPOINT; + } + ++ needed = 1; ++ lower = 0x80; ++ upper = 0xBF; + cp = ch & 0x1F; +- +- if (p[1] < 0x80 || p[1] > 0xBF) { +- return LXB_CSS_SYNTAX_ERROR_CODEPOINT; +- } +- +- cp = (cp << 6) | (p[1] & 0x3F); +- +- *data += 2; + } +- else if (ch < 0xF0) { ++ else if (ch <= 0xEF) { ++ needed = 2; ++ lower = (ch == 0xE0) ? 0xA0 : 0x80; ++ upper = (ch == 0xED) ? 0x9F : 0xBF; + cp = ch & 0x0F; +- +- if (p + 2 >= end) { +- return LXB_CSS_SYNTAX_ERROR_CODEPOINT; +- } +- +- if (ch == 0xE0) { +- if (p[1] < 0xA0 || p[1] > 0xBF) { +- return LXB_CSS_SYNTAX_ERROR_CODEPOINT; +- } +- } +- +- /* +- * We returning surrogate pair! +- */ +-/* +- else if (ch == 0xED) { +- if (p[1] < 0x80 || p[1] > 0x9F) { +- return LXB_CSS_SYNTAX_ERROR_CODEPOINT; +- } +- } +- */ +- else if (p[1] < 0x80 || p[1] > 0xBF) { +- return LXB_CSS_SYNTAX_ERROR_CODEPOINT; +- } +- +- if (p[2] < 0x80 || p[2] > 0xBF) { +- return LXB_CSS_SYNTAX_ERROR_CODEPOINT; +- } +- +- cp = (cp << 6) | (p[1] & 0x3F); +- cp = (cp << 6) | (p[2] & 0x3F); +- +- *data += 3; + } +- else if (ch < 0xF5) { ++ else if (ch <= 0xF4) { ++ needed = 3; ++ lower = (ch == 0xF0) ? 0x90 : 0x80; ++ upper = (ch == 0xF4) ? 0x8F : 0xBF; + cp = ch & 0x07; ++ } ++ else { ++ /* 0xF5..0xFF: an invalid lead byte. */ ++ *data = p; ++ return LXB_CSS_SYNTAX_ERROR_CODEPOINT; ++ } + +- if (p + 3 >= end) { +- return LXB_CSS_SYNTAX_ERROR_CODEPOINT; +- } +- +- if (ch == 0xF0) { +- if (p[1] < 0x90 || p[1] > 0xBF) { +- return LXB_CSS_SYNTAX_ERROR_CODEPOINT; +- } +- } +- else if (ch == 0xF4) { +- if (p[1] < 0x80 || p[1] > 0x8F) { +- return LXB_CSS_SYNTAX_ERROR_CODEPOINT; +- } +- } +- else if (p[1] < 0x80 || p[1] > 0xBF) { +- return LXB_CSS_SYNTAX_ERROR_CODEPOINT; +- } +- +- if ((p[2] < 0x80 || p[2] > 0xBF) || (p[3] < 0x80 || p[3] > 0xBF)) { ++ do { ++ if (p >= end || *p < lower || *p > upper) { ++ *data = p; + return LXB_CSS_SYNTAX_ERROR_CODEPOINT; + } + +- cp = (cp << 6) | (p[1] & 0x3F); +- cp = (cp << 6) | (p[2] & 0x3F); +- cp = (cp << 6) | (p[3] & 0x3F); ++ cp = (cp << 6) | (*p++ & 0x3F); + +- *data += 4; +- } +- else { +- return LXB_CSS_SYNTAX_ERROR_CODEPOINT; ++ lower = 0x80; ++ upper = 0xBF; + } ++ while (--needed != 0); ++ ++ *data = p; + + return cp; + } diff --git a/ext/lexbor/patches/0025-CSS-Syntax-fixed-UTF-8-escapes-in-ident-sequences.patch b/ext/lexbor/patches/0025-CSS-Syntax-fixed-UTF-8-escapes-in-ident-sequences.patch new file mode 100644 index 000000000000..8f90693abc40 --- /dev/null +++ b/ext/lexbor/patches/0025-CSS-Syntax-fixed-UTF-8-escapes-in-ident-sequences.patch @@ -0,0 +1,60 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Alexander Borisov <lex.borisov@gmail.com> +Date: Thu, 9 Jul 2026 23:24:05 +0300 +Subject: [PATCH 25/26] CSS::Syntax: fixed UTF-8 escapes in ident sequences. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Non-hex escapes consumed only the first byte of a UTF-8 sequence and used it +as a code point. Because of this, "a\é" became "aÃ�" instead of "aé". +The same issue affected unquoted URL tokens. +--- + source/lexbor/css/syntax/state.c | 20 +++++++++++++++++++- + 1 file changed, 19 insertions(+), 1 deletion(-) + +diff --git a/source/lexbor/css/syntax/state.c b/source/lexbor/css/syntax/state.c +index abcf930..a1db76a 100644 +--- a/source/lexbor/css/syntax/state.c ++++ b/source/lexbor/css/syntax/state.c +@@ -628,6 +628,17 @@ lxb_css_syntax_state_hash(lxb_css_syntax_tokenizer_t *tkz, + return lxb_css_syntax_state_delim_set(token, data - 1, '#'); + } + ++ if (*data >= 0x80) { ++ begin = data; ++ ++ if (lxb_css_syntax_state_start_ident_utf_8_80(&data, end)) { ++ data = begin; ++ goto hash; ++ } ++ ++ return lxb_css_syntax_state_delim_set(token, begin - 1, '#'); ++ } ++ + if (lxb_css_syntax_res_name_map[*data] == 0x00) { + if (*data == 0x00) { + goto hash; +@@ -1201,6 +1212,7 @@ lxb_css_syntax_state_consume_ident(lxb_css_syntax_tokenizer_t *tkz, + else { + LXB_CSS_SYNTAX_UTF_8_UP_80_BLOCK(tkz, begin, data, end) + else if (!lxb_css_syntax_state_non_ascii(cp)) { ++ data = _bad; + break; + } + } +@@ -1629,7 +1641,13 @@ lxb_css_syntax_state_escaped(lxb_css_syntax_tokenizer_t *tkz, + + if (lexbor_str_res_map_hex[*data] == 0xFF) { + if (count == 0) { +- cp = (lxb_codepoint_t) *data++; ++ if (*data < 0x80) { ++ cp = (lxb_codepoint_t) *data++; ++ } ++ else { ++ cp = lxb_css_syntax_state_decode_utf_8_up_80(&data, end); ++ } ++ + goto done; + } + diff --git a/ext/lexbor/patches/0026-CSS-Syntax-fixed-non-ASCII-ident-code-points.patch b/ext/lexbor/patches/0026-CSS-Syntax-fixed-non-ASCII-ident-code-points.patch new file mode 100644 index 000000000000..660467946460 --- /dev/null +++ b/ext/lexbor/patches/0026-CSS-Syntax-fixed-non-ASCII-ident-code-points.patch @@ -0,0 +1,102 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Alexander Borisov <lex.borisov@gmail.com> +Date: Fri, 10 Jul 2026 00:39:54 +0300 +Subject: [PATCH 26/26] CSS::Syntax: fixed non-ASCII ident code points. + +Updated generated non-ASCII ident ranges to match CSS Syntax: +included U+200C/U+200D and U+203F/U+2040, and stopped the +U+3001 range at U+D7FF to exclude surrogate code points. +--- + source/lexbor/css/syntax/state.c | 45 ++++++++++++++++++-------------- + 1 file changed, 25 insertions(+), 20 deletions(-) + +diff --git a/source/lexbor/css/syntax/state.c b/source/lexbor/css/syntax/state.c +index a1db76a..5b694e9 100644 +--- a/source/lexbor/css/syntax/state.c ++++ b/source/lexbor/css/syntax/state.c +@@ -149,15 +149,10 @@ lxb_css_syntax_state_valid_escape(const lxb_char_t *data, + lxb_inline bool + lxb_css_syntax_state_non_ascii(lxb_codepoint_t cp) + { +- /* +- * Actually here the comparison should be to U+D7FF. +- * But we capture surrogate pairs, they will be further converted to 0xFFFD. +- */ +- + /* This code is generated by the file utils/lexbor/css/syntax/non_ascii.pl */ + + /* Begin */ +- if (cp <= 0x218F) { ++ if (cp <= 0x2040) { + if (cp <= 0x00F6) { + if (cp >= 0x00B7 && cp <= 0x00B7) { + return true; +@@ -172,36 +167,46 @@ lxb_css_syntax_state_non_ascii(lxb_codepoint_t cp) + } + } + else if (cp >= 0x00F8) { +- if (cp <= 0x037D) { +- return true; ++ if (cp <= 0x1FFF) { ++ if (cp <= 0x037D) { ++ return true; ++ } ++ else if (cp >= 0x037F) { ++ return true; ++ } + } +- else if (cp >= 0x037F) { +- if (cp <= 0x1FFF) { ++ else if (cp >= 0x200C) { ++ if (cp <= 0x200D) { + return true; + } +- else if (cp >= 0x2070) { ++ else if (cp >= 0x203F) { + return true; + } + } + } + } +- else if (cp >= 0x2C00) { +- if (cp <= 0xFDCF) { +- if (cp <= 0x2FEF) { ++ else if (cp >= 0x2070) { ++ if (cp <= 0xD7FF) { ++ if (cp <= 0x218F) { + return true; + } +- else if (cp >= 0x3001) { +- if (cp <= 0xDFFF) { ++ else if (cp >= 0x2C00) { ++ if (cp <= 0x2FEF) { + return true; + } +- else if (cp >= 0xF900) { ++ else if (cp >= 0x3001) { + return true; + } + } + } +- else if (cp >= 0xFDF0) { ++ else if (cp >= 0xF900) { + if (cp <= 0xFFFD) { +- return true; ++ if (cp <= 0xFDCF) { ++ return true; ++ } ++ else if (cp >= 0xFDF0) { ++ return true; ++ } + } + else if (cp >= 0x10000) { + if (cp <= 0x10FFFF) { +@@ -212,7 +217,7 @@ lxb_css_syntax_state_non_ascii(lxb_codepoint_t cp) + } + /* End */ + +- return cp == 0x200C || cp == 0x200D || cp == 0x203F || cp == 0x2040; ++ return false; + } + + lxb_inline bool

« previous php.cvs (#143995) next »