code wiki / (root) / nx_url_resolve.nx

nx_url_resolve.nx

buildroot/runtime/nx_url_resolve.nx

14949 B367 linesdepth 2pulls 2 transitivereach 30 importersview sourcekind librarytopic url
docsdependenciesstructsconstsfunctions

about

nx_url_resolve.nx -- RFC 3986 §5.2 relative-URL resolution. Given a base URL (assumed absolute: scheme://authority/path...) and a reference URL (absolute, scheme-relative, path-absolute, path-relative, or fragment-only), compute the resolved absolute URL and write it to caller-supplied output buffer. This is the substrate primitive Arc B2 needs to turn the raw <img src="..."> values harvested from a Google response into fetchable absolute URLs. Covered cases (in roughly the order RFC 3986 §5.2 specifies): - rel is absolute (has its own scheme): output = rel verbatim - rel starts with "//": output = base.scheme + ":" + rel - rel starts with "/": output = base.scheme + "://" + base.authority + rel - rel is empty or "#frag": output = base with optional new fragment - rel is path-relative: output = base.scheme + "://" + base.authority + merged-and-dot-resolved path + rel.query/frag Out of scope (deferred to a real-Google-response-driven slice): - userinfo (user:pass@host) - IPv6 [..] hosts - punycode/IDN - normalize_case of host (spec says lower) - percent-decode/re-encode round-trip nx_safety_envelope: intended_use: "Relative-URL resolution for HTML href/src in the bits-up browser substrate." sil_target: SIL1 evidence: [RFC3986_section_5_2_canonical_basis, bounded_output_buffer, substrate_honest_truncation_signal] hazard_register: [bug-tape-path-traversal-via-dot-dot, bug-tape-host-substitution-via-malformed-base] residual_risk: "Caller is responsible for sandboxing fetch targets; resolver does not enforce origin policy." verdict: NOT_YET_EVALUATED

dependencies 1 imports · 8 importers

nx_syscalls.nx nx_url_resolve.nx nx_browser.nx nx_html_extract_imgs.nx nx_html_extract_links.nx nx_http_resolve_redirect.nx nx_media_deepcrawl.nx nx_media_harvest.nx nx_redirect_resolve.nx nx_url_resolve_test.nx

imports: nx_syscalls.nx

imported by: nx_browser.nxnx_html_extract_imgs.nxnx_html_extract_links.nxnx_http_resolve_redirect.nxnx_media_deepcrawl.nxnx_media_harvest.nxnx_redirect_resolve.nxnx_url_resolve_test.nx

structs

none

consts

44const NX_URL_RESOLVE_OK: i64 = 0
45const NX_URL_RESOLVE_TRUNC: i64 = -1 // output buffer too small
46const NX_URL_RESOLVE_BAD_BASE: i64 = -2 // base is not a usable absolute URL

functions

48func _ur_lc(b: i64) -> i64
55func _ur_find_scheme_colon(s: *u8, slen: i64) -> i64
called by 1: nx_url_resolve calls 1: _ur_lc
82func _ur_putc(out: *u8, pos: i64, cap: i64, b: i64) -> i64
89func _ur_copy(out: *u8, pos: i64, cap: i64, src: *u8, so: i64, sn: i64) -> i64
112func _ur_resolve_dot_segments(path: *u8, plen: i64,
called by 1: nx_url_resolve calls 2: _ur_putc_ur_copy
192func nx_url_resolve(base: *u8, base_len: i64,