leanprover / lean4

Lean 4 programming language and theorem prover
https://lean-lang.org
Apache License 2.0
4.46k stars 388 forks source link

ToString instance for Xml does not correctly escape #4411

Open eric-wieser opened 2 months ago

eric-wieser commented 2 months ago

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

While the XML parser correctly handles XML escape sequences, the stringifier does not emit them.

Context

Zulip thread. This leads to some mangled markdown in doc-gen, which unknowingly tries to work around this bug.

Steps to Reproduce

Run the following:

import Lean

run_cmd do
  let .ok doc := Lean.Xml.parse "<b class=\"&quot;\">hello &lt; world </b>" | unreachable!
  Lean.logInfo (toString doc)

Expected behavior: The output is <b class="&quot;">hello &lt; world </b>

Actual behavior: The output is <b class=""">hello < world </b>, which is invalid XML

Versions

4.9.0-rc1
4.10.0-nightly-2024-06-09

Additional Information

[Additional information, configuration or data that might be necessary to reproduce the issue]

Impact

Add :+1: to issues you consider important. If others are impacted by this issue, please ask them to add :+1: to it.

acmepjz commented 1 month ago

I'd like to open a PR to fix this. Any suggestions?