diff --git a/abaplint.json b/abaplint.json index 4029d5abb..4be5c023d 100644 --- a/abaplint.json +++ b/abaplint.json @@ -177,7 +177,10 @@ "exclude": ["/json/"] }, "7bit_ascii": { - "exclude": ["zcl_abapgit_utils.clas.testclasses.abap"] + "exclude": [ + "zcl_abapgit_utils.clas.testclasses.abap", + "zcl_abapgit_html_action_utils.clas.testclasses.abap" + ] }, "abapdoc": false, "check_ddic": true, diff --git a/package.json b/package.json index 61ec1ba43..4429042eb 100644 --- a/package.json +++ b/package.json @@ -26,8 +26,8 @@ }, "devDependencies": { "@abaplint/cli": "^2.89.14", - "@abaplint/runtime": "^2.0.16", - "@abaplint/transpiler-cli": "^2.0.16", + "@abaplint/runtime": "^2.0.18", + "@abaplint/transpiler-cli": "^2.0.18", "@abaplint/database-sqlite": "^2.0.11", "abapmerge": "^0.14.3", "c8": "^7.11.2", diff --git a/src/ui/zcl_abapgit_html_action_utils.clas.abap b/src/ui/zcl_abapgit_html_action_utils.clas.abap index 59855f70b..90226b369 100644 --- a/src/ui/zcl_abapgit_html_action_utils.clas.abap +++ b/src/ui/zcl_abapgit_html_action_utils.clas.abap @@ -6,8 +6,8 @@ CLASS zcl_abapgit_html_action_utils DEFINITION CLASS-METHODS parse_post_form_data IMPORTING - !it_post_data TYPE zif_abapgit_html_viewer=>ty_post_data - !iv_upper_cased TYPE abap_bool DEFAULT abap_false + !it_post_data TYPE zif_abapgit_html_viewer=>ty_post_data + !iv_upper_cased TYPE abap_bool DEFAULT abap_false RETURNING VALUE(rt_fields) TYPE tihttpnvp . CLASS-METHODS parse_fields @@ -23,7 +23,7 @@ CLASS zcl_abapgit_html_action_utils DEFINITION VALUE(rt_fields) TYPE tihttpnvp . CLASS-METHODS translate_postdata IMPORTING - !it_postdata TYPE zif_abapgit_html_viewer=>ty_post_data + !it_postdata TYPE zif_abapgit_html_viewer=>ty_post_data RETURNING VALUE(rv_string) TYPE string . @@ -90,14 +90,6 @@ ENDCLASS. CLASS zcl_abapgit_html_action_utils IMPLEMENTATION. - METHOD class_constructor. - - CONSTANTS lc_nbsp TYPE xstring VALUE 'C2A0'. "   - - gv_non_breaking_space = zcl_abapgit_convert=>xstring_to_string_utf8( lc_nbsp ). - - ENDMETHOD. - METHOD add_field. @@ -123,6 +115,15 @@ CLASS zcl_abapgit_html_action_utils IMPLEMENTATION. ENDMETHOD. + METHOD class_constructor. + + CONSTANTS lc_nbsp TYPE xstring VALUE 'C2A0'. "   + + gv_non_breaking_space = zcl_abapgit_convert=>xstring_to_string_utf8( lc_nbsp ). + + ENDMETHOD. + + METHOD dbkey_encode. DATA: lt_fields TYPE tihttpnvp. @@ -253,16 +254,16 @@ CLASS zcl_abapgit_html_action_utils IMPLEMENTATION. LOOP AT lt_substrings ASSIGNING . CLEAR ls_field. - = unescape( ). " On attempt to change unescaping -> run unit tests to check ! - ls_field-name = substring_before( + " Unescape name and value separately + ls_field-name = unescape( substring_before( val = - sub = '=' ). + sub = '=' ) ). - ls_field-value = substring_after( + ls_field-value = unescape( substring_after( val = - sub = '=' ). + sub = '=' ) ). IF ls_field IS INITIAL. " Not a field with proper structure CONTINUE. @@ -341,9 +342,11 @@ CLASS zcl_abapgit_html_action_utils IMPLEMENTATION. rv_string = iv_string. * todo, more to be added here - REPLACE ALL OCCURRENCES OF '%3F' IN rv_string WITH '?'. - REPLACE ALL OCCURRENCES OF '%3D' IN rv_string WITH '='. - REPLACE ALL OCCURRENCES OF '%2f' IN rv_string WITH '/'. + REPLACE ALL OCCURRENCES OF '%3F' IN rv_string WITH '?' IGNORING CASE. + REPLACE ALL OCCURRENCES OF '%3D' IN rv_string WITH '=' IGNORING CASE. + REPLACE ALL OCCURRENCES OF '%2F' IN rv_string WITH '/' IGNORING CASE. + REPLACE ALL OCCURRENCES OF '%25' IN rv_string WITH '%' IGNORING CASE. + REPLACE ALL OCCURRENCES OF '%26' IN rv_string WITH '&' IGNORING CASE. REPLACE ALL OCCURRENCES OF gv_non_breaking_space IN rv_string WITH ` `. ENDMETHOD. diff --git a/src/ui/zcl_abapgit_html_action_utils.clas.testclasses.abap b/src/ui/zcl_abapgit_html_action_utils.clas.testclasses.abap index 07640886c..d6a5bc343 100644 --- a/src/ui/zcl_abapgit_html_action_utils.clas.testclasses.abap +++ b/src/ui/zcl_abapgit_html_action_utils.clas.testclasses.abap @@ -13,6 +13,7 @@ CLASS ltcl_html_action_utils DEFINITION FOR TESTING RISK LEVEL HARMLESS METHODS parse_fields_wrong_format FOR TESTING. METHODS parse_post_form_data FOR TESTING. METHODS parse_fields_webgui FOR TESTING. + METHODS parse_fields_special_chars FOR TESTING. PRIVATE SECTION. @@ -374,4 +375,22 @@ CLASS ltcl_html_action_utils IMPLEMENTATION. ENDMETHOD. + METHOD parse_fields_special_chars. + + DATA lv_string TYPE string. + + " URL encoded data + lv_string = `TEST=!"#$%25%26'()*+,-./09:;<%3d>?@AZ[\]^_``az{|}~¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿`. + + _given_string_is( lv_string ). + _when_fields_are_parsed( ). + _then_field_count_should_be( 1 ). + + _then_fields_should_be( + iv_index = 1 + iv_name = 'TEST' + iv_value = `!"#$%&'()*+,-./09:;<=>?@AZ[\]^_``az{|}~¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿` ). + + ENDMETHOD. + ENDCLASS.