Skip to content

Commit beee544

Browse files
lexbor: Merge upstream WHATWG URL and IDNA fixes
lexbor/lexbor@859f100 lexbor/lexbor@a36e09a lexbor/lexbor@b0f7412 lexbor/lexbor@1b215a8 lexbor/lexbor@385afff lexbor/lexbor@e6c068f lexbor/lexbor@327a8b6 lexbor/lexbor@917742f lexbor/lexbor@e89c258 Only the source/lexbor/url part of lexbor/lexbor@327a8b6 and lexbor/lexbor@e89c258 is carried: the first squash also contains unrelated HTML tree construction changes, and the second documents a percent-encoder API that this branch does not bundle.
1 parent f590d93 commit beee544

30 files changed

Lines changed: 1200 additions & 132 deletions

File tree

‎NEWS‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ PHP NEWS
8787
. Merge patches lexbor/lexbor@8a14bc0 and lexbor/lexbor@f67ce4b, fixing a
8888
heap buffer overflow in :lexbor-contains() parsing and buffer overflows
8989
in malformed decode replay. (alexandre-daubois)
90+
. Merge patches lexbor/lexbor@859f100, lexbor/lexbor@a36e09a,
91+
lexbor/lexbor@b0f7412, lexbor/lexbor@1b215a8, lexbor/lexbor@385afff,
92+
lexbor/lexbor@e6c068f, lexbor/lexbor@327a8b6, lexbor/lexbor@917742f and
93+
lexbor/lexbor@e89c258, fixing dropped usernames containing an at sign,
94+
uninitialized memory in IDNA buffer growth, the encoding of a space
95+
before a query or fragment in an opaque path, a query or fragment lost
96+
after a dot segment in a path, replacement file drive paths, the output
97+
encoding used for percent-encoding, the URLSearchParams tail pointer and
98+
fragment serialization without a query. (alexandre-daubois)
9099

91100
- MBString:
92101
. Fixed bug GH-23106 (mb_strpos() reads past the end of a haystack ending in

‎ext/lexbor/lexbor/unicode/idna.c‎

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,14 @@ lxb_unicode_idna_realloc(lxb_codepoint_t *buf, const lxb_codepoint_t *buffer,
117117
lxb_codepoint_t *tmp;
118118

119119
nlen = ((*buf_end - buf) * 4) + len;
120-
120+
121121
if (buf == buffer) {
122122
tmp = lexbor_malloc(nlen * sizeof(lxb_codepoint_t));
123123
if (tmp == NULL) {
124124
return NULL;
125125
}
126+
127+
memcpy(tmp, buf, (*buf_p - buf) * sizeof(lxb_codepoint_t));
126128
}
127129
else {
128130
tmp = lexbor_realloc(buf, nlen * sizeof(lxb_codepoint_t));
@@ -458,13 +460,17 @@ lxb_unicode_idna_ascii_puny_cb(const lxb_char_t *data, size_t length, void *ctx,
458460

459461
if (asc->buf == asc->buffer) {
460462
tmp = lexbor_malloc(nlen);
463+
if (tmp == NULL) {
464+
return LXB_STATUS_ERROR_MEMORY_ALLOCATION;
465+
}
466+
467+
memcpy(tmp, asc->buf, asc->p - asc->buf);
461468
}
462469
else {
463470
tmp = lexbor_realloc(asc->buf, nlen);
464-
}
465-
466-
if (tmp == NULL) {
467-
return LXB_STATUS_ERROR_MEMORY_ALLOCATION;
471+
if (tmp == NULL) {
472+
return LXB_STATUS_ERROR_MEMORY_ALLOCATION;
473+
}
468474
}
469475

470476
asc->p = tmp + (asc->p - asc->buf);
@@ -711,13 +717,17 @@ lxb_unicode_idna_to_unicode_cb(const lxb_codepoint_t *part, size_t len,
711717

712718
if (asc->buf == asc->buffer) {
713719
tmp = lexbor_malloc(nlen);
720+
if (tmp == NULL) {
721+
return LXB_STATUS_ERROR_MEMORY_ALLOCATION;
722+
}
723+
724+
memcpy(tmp, asc->buf, asc->p - asc->buf);
714725
}
715726
else {
716727
tmp = lexbor_realloc(asc->buf, nlen);
717-
}
718-
719-
if (tmp == NULL) {
720-
return LXB_STATUS_ERROR_MEMORY_ALLOCATION;
728+
if (tmp == NULL) {
729+
return LXB_STATUS_ERROR_MEMORY_ALLOCATION;
730+
}
721731
}
722732

723733
asc->p = tmp + (asc->p - asc->buf);

0 commit comments

Comments
 (0)