XSLT: Add check for correct EOL separator (#6803)

Co-authored-by: Lars Hvam <larshp@hotmail.com>
This commit is contained in:
Marc Bernard 2024-02-10 15:13:22 +01:00 committed by GitHub
parent 05c9a33c57
commit fa66b626de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 0 deletions

View File

@ -12,6 +12,10 @@ trim_trailing_whitespace = true
indent_style = space
indent_size = 1
# XSLT source code must have CR LF to be deserialized correctly by SAP code
[*.xslt.source.xml]
end_of_line = crlf
# match the format used by abapGit
[*.{abap,js,json,html,css}]
charset = utf-8

View File

@ -122,6 +122,8 @@ CLASS zcl_abapgit_object_xslt IMPLEMENTATION.
iv_extra = 'source'
iv_ext = 'xml' ).
zcl_abapgit_utils=>check_eol( lv_source ).
* workaround: somewhere additional linefeeds are added
lv_len = strlen( lv_source ) - 2.
IF lv_source+lv_len(2) = cl_abap_char_utilities=>cr_lf.

View File

@ -15,6 +15,11 @@ CLASS zcl_abapgit_utils DEFINITION
iv_email TYPE string
RETURNING
VALUE(rv_valid) TYPE abap_bool.
CLASS-METHODS check_eol
IMPORTING
!iv_data TYPE string
RAISING
zcx_abapgit_exception.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
@ -24,6 +29,19 @@ ENDCLASS.
CLASS zcl_abapgit_utils IMPLEMENTATION.
METHOD check_eol.
" Check if data is using CRLF as EOL separator. If only LF is used, data was likely
" edited by externtal tools
IF iv_data IS NOT INITIAL AND
iv_data CS cl_abap_char_utilities=>newline AND
iv_data NS cl_abap_char_utilities=>cr_lf.
zcx_abapgit_exception=>raise( 'Incorrect source format: Requires CRLF instead of LF' ).
ENDIF.
ENDMETHOD.
METHOD is_binary.
" Previously we did a simple char range test described here