Skip to content

Preserve Unicode through byte-mode HTML parser captures and re-flagging #1183

Description

@fglock

Summary

PerlOnJava corrupts Unicode values in the byte-mode parser flow used by HTML::Defang. The distribution byte-parses an UTF-8-flagged HTML scalar under use bytes, re-enables the UTF-8 flag on extracted attribute values with Encode::_utf8_on, and expects those values and the assembled output to remain Unicode.

CPAN impact

HTML::Defang 1.09 failed in CPAN tester run 20260827-171032-2227. Its t/06_unicode.t failed 7 of 19 checks on both JVM and interpreter backends. Attribute callback values fail equality checks, and output contains mojibake such as the UTF-8 byte rendering of the Japanese character 岡 instead of the original character.

System Perl baseline

System Perl passes the unchanged HTML::Defang 1.09 suite completely: 9 files, 635 tests, Result: PASS.

Scope

Simple use bytes capture probes preserve byte semantics correctly on PerlOnJava, so this is not yet shown to be the same root cause as Template filter callback issue #1182. The failing shape combines global parser matching, extraction of attributes/content, Encode::_utf8_on, and output concatenation.

Acceptance criteria

  • Add a project-owned system-Perl-validated regression covering the smallest parser/capture/re-flagging sequence that reproduces the corruption.
  • Preserve correct character values and UTF-8 flags for callback attributes and parser output on JVM and interpreter backends.
  • HTML::Defang 1.09 t/06_unicode.t passes on both backends.
  • Retain byte semantics for ordinary use bytes regex captures.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions