Escape XML special characters in XSLT transformation enum values - #341
Markus1812 with Copilot wants to merge 34 commits into
Conversation
…erator Co-authored-by: Markus1812 <7271378+Markus1812@users.noreply.github.com>
Co-authored-by: Markus1812 <7271378+Markus1812@users.noreply.github.com>
| validate_output( act_output ). | ||
| ENDMETHOD. | ||
|
|
||
| METHOD struc_with_special_char_enums. |
There was a problem hiding this comment.
Integration test in ltcl_integration_test_ad missing
There was a problem hiding this comment.
Integration test in ltcl_integration_test_ad missing
@copilot
There was a problem hiding this comment.
Added integration test struc_with_special_char_enums in ltcl_integration_test_ad that tests round-trip serialization/deserialization for all three special characters (<, >, &). Commit: 5fb3ed0
Co-authored-by: Markus1812 <7271378+Markus1812@users.noreply.github.com>
Added integration test |
| METHOD escape_xml_chars. | ||
| result = value. | ||
| " Ampersand must be replaced first to avoid double-escaping | ||
| REPLACE ALL OCCURRENCES OF '&' IN result WITH '&'. | ||
| REPLACE ALL OCCURRENCES OF '<' IN result WITH '<'. | ||
| REPLACE ALL OCCURRENCES OF '>' IN result WITH '>'. | ||
| REPLACE ALL OCCURRENCES OF '"' IN result WITH '"'. | ||
| REPLACE ALL OCCURRENCES OF '''' IN result WITH '''. | ||
| ENDMETHOD. | ||
|
|
There was a problem hiding this comment.
Can't we use ABAP's built-in function escape to escape xml?
See https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/ABENESCAPE_FUNCTIONS.html
This reverts commit 9fc7c57.
* update npm dependencies * update * run another testcase * update
* Fix download (and unit test) * fix linter issue
* update npm dependencies * update
Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) from 5.4.2 to 5.5.6. - [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases) - [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md) - [Commits](NaturalIntelligence/fast-xml-parser@v5.4.2...v5.5.6) --- updated-dependencies: - dependency-name: fast-xml-parser dependency-version: 5.5.6 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) from 5.5.6 to 5.5.7. - [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases) - [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md) - [Commits](NaturalIntelligence/fast-xml-parser@v5.5.6...v5.5.7) --- updated-dependencies: - dependency-name: fast-xml-parser dependency-version: 5.5.7 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [@abaplint/transpiler-cli](https://github.com/abaplint/transpiler) from 2.13.15 to 2.13.21. - [Changelog](https://github.com/abaplint/transpiler/blob/main/CHANGELOG.md) - [Commits](https://github.com/abaplint/transpiler/commits) --- updated-dependencies: - dependency-name: "@abaplint/transpiler-cli" dependency-version: 2.13.21 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [@abaplint/runtime](https://github.com/abaplint/transpiler) from 2.13.15 to 2.13.22. - [Changelog](https://github.com/abaplint/transpiler/blob/main/CHANGELOG.md) - [Commits](https://github.com/abaplint/transpiler/commits) --- updated-dependencies: - dependency-name: "@abaplint/runtime" dependency-version: 2.13.21 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [@abaplint/cli](https://github.com/abaplint/abaplint) from 2.119.2 to 2.119.14. - [Release notes](https://github.com/abaplint/abaplint/releases) - [Commits](https://github.com/abaplint/abaplint/commits) --- updated-dependencies: - dependency-name: "@abaplint/cli" dependency-version: 2.119.12 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Michael Schneider <micha.schneider@sap.com>
* chore(hyperspace): 🤖 Add PR Bot Configuration * Update pull_request_bot.json --------- Co-authored-by: hyperspace-insights[bot] <209611008+hyperspace-insights[bot]@users.noreply.github.com> Co-authored-by: Albert Mink <albert.mink@sap.com>
* update npm dependencies * audit fix
Bumps [@abaplint/transpiler-cli](https://github.com/abaplint/transpiler) from 2.13.30 to 2.13.31. - [Changelog](https://github.com/abaplint/transpiler/blob/main/CHANGELOG.md) - [Commits](https://github.com/abaplint/transpiler/commits) --- updated-dependencies: - dependency-name: "@abaplint/transpiler-cli" dependency-version: 2.13.31 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Remove Callback Handling * Fix lint * Remove ignore_til_indent_level and fix minors * Fix minor * Fix indentations * Fix lint * Remove method * Fix AbapLint --------- Co-authored-by: Sara Spangenmacher <s.spangenmacher@sap.com> Co-authored-by: k4llist0 <93997474+k4llist0@users.noreply.github.com>
Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com>
Fix Transformation Generator Special Character Escaping
This PR fixes the issue where the transformation generator does not properly escape special XML characters in enum values.
Progress:
get_abap_valuemethodTechnical Details:
The issue occurs in
zcl_aff_writer_xslt.clas.abapwhere enum values are written to the XSLT transformation without proper XML escaping.Changes made:
Added
escape_xml_charsmethod to escape special XML characters:&→&(escaped first to prevent double-escaping)<→<>→>"→"'→'Modified
get_abap_valuemethod to apply escaping to character and numeric text valuesAdded test case
struc_with_special_char_enumsto verify the fix works correctly with enum values containing<,>, and&Added integration test in
ltcl_integration_test_adthat tests the round-trip serialization/deserialization of special character enum valuesThe fix ensures that enum values with special XML characters are properly escaped in the generated XSLT transformation, preventing XML syntax errors. The ampersand is escaped first to avoid double-escaping of the escape sequences themselves.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.