Skip to content

fix(upnp): accept Unicode device descriptions safely - #6

Merged
agalwood merged 1 commit into
mainfrom
fix/5_unicode_xml_validation
Oct 1, 2026
Merged

agalwood merged 1 commit into
mainfrom
fix/5_unicode_xml_validation

Conversation

@agalwood

@agalwood agalwood commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Huawei AX3 descriptions containing <friendlyName>华为路由AX3</friendlyName> were rejected by the ASCII-only XML tokenizer. Accept valid Unicode text and attribute values while retaining the existing restricted XML grammar and security limits.

  • Validate XML 1.0 code points, reject unpaired UTF-16 surrogates, preserve the DEL/C1 control ban and ASCII element/attribute names, and enforce the UTF-8 byte budget.
  • Trim only XML whitespace with linear scans; preserve Unicode whitespace in data and keep controlURL restrictions intact.
  • Validate raw HTTP bytes before UTF-8 decoding, so malformed sequences cannot be silently converted into legal U+FFFD characters. Legitimately encoded U+FFFD remains accepted.
  • Reject unescaped spaces in SSDP LOCATION paths and contain HTTP setup/transport errors so malformed advertisements cannot terminate the process. Discovery can continue with the next response.

Fixes #5.

Validation:

  • All 8 GitHub checks passed: Windows/macOS/Linux on Node 22 and 24, Docker matrix, and fuzz regression.
  • macOS: 616 tests passed.
  • Linux/OrbStack: 623 tests passed, including all 7 Docker integration cases (SSDP discovery, PCP MAP, Unicode metadata, malformed UTF-8, XXE, redirect, and malformed HTTP).
  • Lint, typecheck, and build passed; 60-second codec fuzz completed without crashes.
  • Exhaustive checks covered all 1,114,112 code points in text/attributes, 3,341,952 non-ASCII name cases, 2,376 ASCII differential cases, and 24 Unicode controlURL cases.
  • The whitespace performance regression test times out against the supplied patch and passes with linear trimming. The discovery crash reproduction now completes normally.

No physical-router retest was performed.

@agalwood
agalwood merged commit 2ee2e5c into main Oct 1, 2026
8 checks passed
@agalwood
agalwood deleted the fix/5_unicode_xml_validation branch October 1, 2026 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UPnP discovery fails on Huawei AX3 when device description contains valid UTF-8/Unicode text

1 participant