Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 31x 31x 31x 31x 1x 1x 7x 7x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | CLASS zcl_abapgit_gui_event DEFINITION PUBLIC FINAL CREATE PUBLIC . PUBLIC SECTION. INTERFACES zif_abapgit_gui_event . CLASS-METHODS class_constructor . CLASS-METHODS new IMPORTING !ii_gui_services TYPE REF TO zif_abapgit_gui_services OPTIONAL !iv_action TYPE clike !iv_getdata TYPE clike OPTIONAL !it_postdata TYPE zif_abapgit_html_viewer=>ty_post_data OPTIONAL RETURNING VALUE(ro_instance) TYPE REF TO zcl_abapgit_gui_event. METHODS constructor IMPORTING !ii_gui_services TYPE REF TO zif_abapgit_gui_services OPTIONAL !iv_action TYPE clike !iv_getdata TYPE clike OPTIONAL !it_postdata TYPE zif_abapgit_html_viewer=>ty_post_data OPTIONAL . PROTECTED SECTION. PRIVATE SECTION. DATA mo_query TYPE REF TO zcl_abapgit_string_map. DATA mo_form_data TYPE REF TO zcl_abapgit_string_map. CLASS-DATA gv_non_breaking_space TYPE string . TYPES: BEGIN OF ty_name_value, name TYPE string, value TYPE string, END OF ty_name_value. TYPES ty_name_value_tt TYPE STANDARD TABLE OF ty_name_value WITH DEFAULT KEY. METHODS fields_to_map IMPORTING it_fields TYPE ty_name_value_tt RETURNING VALUE(ro_string_map) TYPE REF TO zcl_abapgit_string_map RAISING zcx_abapgit_exception. 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 RETURNING VALUE(rt_fields) TYPE ty_name_value_tt . CLASS-METHODS parse_fields IMPORTING !iv_string TYPE clike !iv_upper_cased TYPE abap_bool DEFAULT abap_false RETURNING VALUE(rt_fields) TYPE ty_name_value_tt . CLASS-METHODS parse_fields_upper_case_name IMPORTING !iv_string TYPE clike RETURNING VALUE(rt_fields) TYPE ty_name_value_tt . CLASS-METHODS translate_postdata IMPORTING !it_postdata TYPE zif_abapgit_html_viewer=>ty_post_data RETURNING VALUE(rv_string) TYPE string . CLASS-METHODS field_keys_to_upper CHANGING !ct_fields TYPE ty_name_value_tt . CLASS-METHODS unescape IMPORTING !iv_string TYPE string RETURNING VALUE(rv_string) TYPE string . ENDCLASS. CLASS zcl_abapgit_gui_event IMPLEMENTATION. METHOD constructor. " Edge Webview control returns upper case action but abapGit requires lower case (#4841) zif_abapgit_gui_event~mi_gui_services = ii_gui_services. zif_abapgit_gui_event~mv_action = to_lower( iv_action ). zif_abapgit_gui_event~mv_getdata = iv_getdata. zif_abapgit_gui_event~mt_postdata = it_postdata. IF ii_gui_services IS BOUND. zif_abapgit_gui_event~mv_current_page_name = ii_gui_services->get_current_page_name( ). ENDIF. ENDMETHOD. METHOD fields_to_map. FIELD-SYMBOLS <ls_field> LIKE LINE OF it_fields. CREATE OBJECT ro_string_map EXPORTING iv_case_insensitive = abap_true. LOOP AT it_fields ASSIGNING <ls_field>. ro_string_map->set( iv_key = <ls_field>-name iv_val = <ls_field>-value ). ENDLOOP. ENDMETHOD. METHOD new. CREATE OBJECT ro_instance EXPORTING ii_gui_services = ii_gui_services iv_action = iv_action iv_getdata = iv_getdata it_postdata = it_postdata. ENDMETHOD. METHOD zif_abapgit_gui_event~form_data. IF mo_form_data IS NOT BOUND. mo_form_data = fields_to_map( parse_post_form_data( zif_abapgit_gui_event~mt_postdata ) ). mo_form_data->freeze( ). ENDIF. ro_string_map = mo_form_data. ENDMETHOD. METHOD zif_abapgit_gui_event~query. IF mo_query IS NOT BOUND. mo_query = fields_to_map( parse_fields( zif_abapgit_gui_event~mv_getdata ) ). mo_query->freeze( ). ENDIF. ro_string_map = mo_query. ENDMETHOD. METHOD parse_fields_upper_case_name. rt_fields = parse_fields( iv_string = iv_string iv_upper_cased = abap_true ). ENDMETHOD. METHOD parse_post_form_data. DATA lv_serialized_post_data TYPE string. lv_serialized_post_data = translate_postdata( it_post_data ). IF iv_upper_cased = abap_true. rt_fields = parse_fields_upper_case_name( lv_serialized_post_data ). ELSE. rt_fields = parse_fields( lv_serialized_post_data ). ENDIF. ENDMETHOD. METHOD parse_fields. DATA: lt_substrings TYPE string_table, ls_field LIKE LINE OF rt_fields. FIELD-SYMBOLS <lv_substring> LIKE LINE OF lt_substrings. SPLIT iv_string AT '&' INTO TABLE lt_substrings. LOOP AT lt_substrings ASSIGNING <lv_substring>. CLEAR ls_field. " On attempt to change unescaping -> run unit tests to check ! " Unescape name and value separately ls_field-name = unescape( substring_before( val = <lv_substring> sub = '=' ) ). ls_field-value = unescape( substring_after( val = <lv_substring> sub = '=' ) ). IF ls_field IS INITIAL. " Not a field with proper structure CONTINUE. ENDIF. APPEND ls_field TO rt_fields. ENDLOOP. IF iv_upper_cased = abap_true. field_keys_to_upper( CHANGING ct_fields = rt_fields ). ENDIF. ENDMETHOD. METHOD translate_postdata. DATA: lt_post_data TYPE zif_abapgit_html_viewer=>ty_post_data, ls_last_line LIKE LINE OF it_postdata, lv_last_line_index TYPE i. IF it_postdata IS INITIAL. RETURN. "Nothing to do ENDIF. lt_post_data = it_postdata. "Save the last line for separate merge, because we don't need its trailing spaces WHILE ls_last_line IS INITIAL. lv_last_line_index = lines( lt_post_data ). READ TABLE lt_post_data INTO ls_last_line INDEX lv_last_line_index. DELETE lt_post_data INDEX lv_last_line_index. ENDWHILE. CONCATENATE LINES OF lt_post_data INTO rv_string IN CHARACTER MODE RESPECTING BLANKS. CONCATENATE rv_string ls_last_line INTO rv_string IN CHARACTER MODE. ENDMETHOD. METHOD field_keys_to_upper. FIELD-SYMBOLS <ls_field> LIKE LINE OF ct_fields. LOOP AT ct_fields ASSIGNING <ls_field>. <ls_field>-name = to_upper( <ls_field>-name ). ENDLOOP. ENDMETHOD. METHOD unescape. * do not use cl_http_utility as it does strange things with the encoding rv_string = iv_string. * todo, more to be added here REPLACE ALL OCCURRENCES OF '%3A' IN rv_string WITH ':' IGNORING CASE. 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. METHOD class_constructor. CONSTANTS lc_nbsp TYPE xstring VALUE 'C2A0'. " TRY. gv_non_breaking_space = zcl_abapgit_convert=>xstring_to_string_utf8( lc_nbsp ). CATCH zcx_abapgit_exception. ASSERT 0 = 1. ENDTRY. ENDMETHOD. ENDCLASS. |