-
Notifications
You must be signed in to change notification settings - Fork 122
feat: add XML 1.1 encoding #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
resolves #73
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds XML 1.1 encoding support to the OWASP Encoder library. The key difference between XML 1.0 and XML 1.1 is that XML 1.1 allows control characters to be represented as character references (e.g., ) rather than being replaced with spaces, making it more permissive for modern applications that need to preserve these characters.
- Introduced a
Versionenum to distinguish between XML 1.0 and XML 1.1 encoding rules - Updated the encoding logic to emit hexadecimal character references for restricted control characters in XML 1.1
- Added public API methods
forXml11(),forXml11Content(), andforXml11Attribute()for XML 1.1 encoding
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| core/src/main/java/org/owasp/encoder/XMLEncoder.java | Adds Version enum and version-aware encoding logic for control characters; XML 1.1 encodes C0/C1 control characters as &#xNN; instead of replacing them with spaces |
| core/src/main/java/org/owasp/encoder/Encoders.java | Defines string constants and encoder instances for the three XML 1.1 contexts (general, content, attribute) |
| core/src/main/java/org/owasp/encoder/Encode.java | Exposes public API methods for XML 1.1 encoding with comprehensive documentation |
| core/src/test/java/org/owasp/encoder/XML11EncoderTest.java | Provides comprehensive test coverage for XML 1.1 encoding across all modes and character ranges, though contains a bug in hex formatting for dynamic tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
resolves #73