-
Notifications
You must be signed in to change notification settings - Fork 6
Escape XML special characters in XSLT transformation enum values #341
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
base: main
Are you sure you want to change the base?
Conversation
…erator Co-authored-by: Markus1812 <7271378+Markus1812@users.noreply.github.com>
Co-authored-by: Markus1812 <7271378+Markus1812@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.
Integration test missing
| validate_output( act_output ). | ||
| ENDMETHOD. | ||
|
|
||
| METHOD struc_with_special_char_enums. |
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.
Integration test in ltcl_integration_test_ad missing
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.
Integration test in ltcl_integration_test_ad missing
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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.