Fix #160: Add proper text escaping in FormatHtml#161
Open
bukzor wants to merge 1 commit intosibprogrammer:masterfrom
Open
Fix #160: Add proper text escaping in FormatHtml#161bukzor wants to merge 1 commit intosibprogrammer:masterfrom
bukzor wants to merge 1 commit intosibprogrammer:masterfrom
Conversation
4 tasks
HTML text nodes containing &, <, > were output without escaping, causing xq's output to be unparseable when piped back through xq -j. This commit adds: - New escapeTextContent() function for minimal entity escaping - Modified FormatHtml to escape text nodes with &, <, > - Tests verifying the output is valid XML Example issue: echo '<html>1 & 2</html>' | xq | xq -j # Before: Error - bare & in output # After: Success - properly escaped as & This is a critical fix preventing data corruption when round-tripping HTML through xq. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
b32b900 to
e35e4d8
Compare
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #161 +/- ##
==========================================
+ Coverage 80.57% 80.77% +0.19%
==========================================
Files 5 5
Lines 690 697 +7
==========================================
+ Hits 556 563 +7
Misses 92 92
Partials 42 42 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
&,<,>being output without proper escapingxq | xq -jChanges
escapeTextContent()function for minimal entity escaping (&,<,>)FormatHtml()to escape text nodes properlyTest plan
go test ./...&,<,>in HTML text nodes-jflag)Example
Before this fix:
After this fix:
🤖 Generated with Claude Code