XML::LibXML string parsing mishandles declared encodings

未關閉
#1,989 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
48/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
java, perl, xml
領域
backend

研究方向

Start with src/main/java/org/perlonjava/runtime/perlmodule/XMLLibXML.java, especially xmlInputSource(), and trace how string inputs reach the XML parser. Use the reported failures in t/02gateway.t and the fixtures with ISO-8859-1 declarations as evidence; verify declared-encoding strings, decoded character strings, and BOM-marked byte strings against system Perl behavior.

由索引模型根據 Issue 內容生成。

描述

area:parser area:unicode bug

Summary

PerlOnJava's bundled XML::LibXML returns incorrect character data when parsing the PagSeguro XML fixtures used by Business::CPI::Gateway::PagSeguro 0.904. The upstream distribution passes all 17 tests under system Perl, but fails 3 assertions under PerlOnJava in t/02gateway.t.

Reproduction evidence

CPAN random tester run 20261106-154847-45334:

  • t/02gateway.t failures: notification for completed transaction, notification for failed transaction, and it parses the file correctly.
  • Notification payer name: PerlOnJava returns Jo\uFFFDo da Silva; expected UTF-8 bytes for João da Silva.
  • Transaction payer name: PerlOnJava returns José Comprador; expected José Comprador, matching the system Perl result for the fixture's declared encoding.
  • System Perl oracle: all 17 tests pass, including t/02gateway.t.

The fixtures declare encoding="ISO-8859-1" while containing UTF-8 byte sequences for the accented names. The parser implementation in src/main/java/org/perlonjava/runtime/perlmodule/XMLLibXML.java sends most string inputs to a StringReader in xmlInputSource(). That character-based path bypasses XML byte decoding according to the declaration. The transaction mismatch directly reflects this; the replacement character in notification parsing also points to byte/character conversion on that path and should be covered while fixing it.

Expected behavior

Match system XML::LibXML behavior for string input carrying an XML encoding declaration, including these upstream cases. Preserve correct behavior for already-decoded character strings and BOM-marked byte strings.

Context

The target distribution is pure Perl and uses XML::LibXML; the failing implementation is PerlOnJava's bundled Java provider. No distribution source or tests were modified during classification.

主要語言
Perl
星號
65
分支
8
平均合併
5 小時 57 分鐘
30 天內合併 PR
177

環境準備

  • 提供 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

fglock/PerlOnJava 的其他 Issue

查看 fglock/PerlOnJava 的全部 Issue

相似的 Issue

更多 Perl Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。