Skip to content

Commit 7d24cce

Browse files
committed
Update Lexbor
Cherry-pick lexbor/lexbor@b2dbadc Adding support for IDNA URL serialization.
1 parent 1c09c0c commit 7d24cce

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

ext/lexbor/lexbor/url/url.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4442,9 +4442,9 @@ lxb_url_api_hash_set(lxb_url_t *url, lxb_url_parser_t *parser,
44424442
return status;
44434443
}
44444444

4445-
lxb_status_t
4446-
lxb_url_serialize(const lxb_url_t *url, lexbor_serialize_cb_f cb, void *ctx,
4447-
bool exclude_fragment)
4445+
static lxb_status_t
4446+
lxb_url_serialize_body(lxb_unicode_idna_t *idna, const lxb_url_t *url, lexbor_serialize_cb_f cb,
4447+
void *ctx, bool exclude_fragment)
44484448
{
44494449
lxb_status_t status;
44504450
const lexbor_str_t *str;
@@ -4484,7 +4484,12 @@ lxb_url_serialize(const lxb_url_t *url, lexbor_serialize_cb_f cb, void *ctx,
44844484
lexbor_serialize_write(cb, at_str.data, at_str.length, ctx, status);
44854485
}
44864486

4487-
status = lxb_url_serialize_host(&url->host, cb, ctx);
4487+
if (idna != NULL) {
4488+
status = lxb_url_serialize_host_unicode(idna, &url->host, cb, ctx);
4489+
} else {
4490+
status = lxb_url_serialize_host(&url->host, cb, ctx);
4491+
}
4492+
44884493
if (status != LXB_STATUS_OK) {
44894494
return status;
44904495
}
@@ -4529,6 +4534,20 @@ lxb_url_serialize(const lxb_url_t *url, lexbor_serialize_cb_f cb, void *ctx,
45294534
return LXB_STATUS_OK;
45304535
}
45314536

4537+
lxb_status_t
4538+
lxb_url_serialize(const lxb_url_t *url, lexbor_serialize_cb_f cb, void *ctx,
4539+
bool exclude_fragment)
4540+
{
4541+
return lxb_url_serialize_body(NULL, url, cb, ctx, exclude_fragment);
4542+
}
4543+
4544+
lxb_status_t
4545+
lxb_url_serialize_idna(lxb_unicode_idna_t *idna, const lxb_url_t *url, lexbor_serialize_cb_f cb,
4546+
void *ctx, bool exclude_fragment)
4547+
{
4548+
return lxb_url_serialize_body(idna, url, cb, ctx, exclude_fragment);
4549+
}
4550+
45324551
lxb_status_t
45334552
lxb_url_serialize_scheme(const lxb_url_t *url,
45344553
lexbor_serialize_cb_f cb, void *ctx)

ext/lexbor/lexbor/url/url.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,10 @@ LXB_API lxb_status_t
403403
lxb_url_serialize(const lxb_url_t *url, lexbor_serialize_cb_f cb, void *ctx,
404404
bool exclude_fragment);
405405

406+
LXB_API lxb_status_t
407+
lxb_url_serialize_idna(lxb_unicode_idna_t *idna, const lxb_url_t *url, lexbor_serialize_cb_f cb,
408+
void *ctx, bool exclude_fragment);
409+
406410
LXB_API lxb_status_t
407411
lxb_url_serialize_scheme(const lxb_url_t *url,
408412
lexbor_serialize_cb_f cb, void *ctx);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy