From b41831868f817d5f577244ee4d0391321cc7c396 Mon Sep 17 00:00:00 2001 From: Marc Bernard <59966492+mbtools@users.noreply.github.com> Date: Sat, 2 Oct 2021 03:09:18 -0400 Subject: [PATCH] Fix dump during "New Online" (#4977) * Fix dump during "New Online" I accidentally used a copied link `sapevent:url?url=https://github.com/abapGit-tests/TABL` into the "New Online" diaplog. AG would dump in this case. Now you get a proper error message. * Strip leading/trailing spaces for URLs * Add * Update Co-authored-by: Lars Hvam Co-authored-by: g-back <27279305+g-back@users.noreply.github.com> --- .../zcl_abapgit_gui_page_addonline.clas.abap | 1 + .../zcl_abapgit_gui_page_sett_remo.clas.abap | 1 + src/ui/zcl_abapgit_html_form.clas.abap | 2 ++ src/ui/zcl_abapgit_html_form_utils.clas.abap | 10 +++++++++- src/ui/zif_abapgit_html_form.intf.abap | 1 + src/utils/zcl_abapgit_url.clas.abap | 18 ++++++++---------- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/ui/zcl_abapgit_gui_page_addonline.clas.abap b/src/ui/zcl_abapgit_gui_page_addonline.clas.abap index ea7ba3459..e77a021c5 100644 --- a/src/ui/zcl_abapgit_gui_page_addonline.clas.abap +++ b/src/ui/zcl_abapgit_gui_page_addonline.clas.abap @@ -96,6 +96,7 @@ CLASS zcl_abapgit_gui_page_addonline IMPLEMENTATION. ro_form->text( iv_name = c_id-url iv_required = abap_true + iv_condense = abap_true iv_label = 'Git Repository URL' iv_hint = 'HTTPS address of the repository' iv_placeholder = 'https://github.com/...git' diff --git a/src/ui/zcl_abapgit_gui_page_sett_remo.clas.abap b/src/ui/zcl_abapgit_gui_page_sett_remo.clas.abap index 9f68cad37..8631c8064 100644 --- a/src/ui/zcl_abapgit_gui_page_sett_remo.clas.abap +++ b/src/ui/zcl_abapgit_gui_page_sett_remo.clas.abap @@ -467,6 +467,7 @@ CLASS zcl_abapgit_gui_page_sett_remo IMPLEMENTATION. iv_readonly = abap_true )->text( iv_name = c_id-url + iv_condense = abap_true iv_label = lv_label iv_hint = lv_hint iv_placeholder = lv_placeholder ). diff --git a/src/ui/zcl_abapgit_html_form.clas.abap b/src/ui/zcl_abapgit_html_form.clas.abap index b8a8799be..0195a384c 100644 --- a/src/ui/zcl_abapgit_html_form.clas.abap +++ b/src/ui/zcl_abapgit_html_form.clas.abap @@ -36,6 +36,7 @@ CLASS zcl_abapgit_html_form DEFINITION !iv_upper_case TYPE abap_bool DEFAULT abap_false !iv_readonly TYPE abap_bool DEFAULT abap_false !iv_password TYPE abap_bool DEFAULT abap_false + !iv_condense TYPE abap_bool OPTIONAL !iv_placeholder TYPE csequence OPTIONAL !iv_side_action TYPE csequence OPTIONAL !iv_min TYPE i DEFAULT cl_abap_math=>min_int4 @@ -817,6 +818,7 @@ CLASS zcl_abapgit_html_form IMPLEMENTATION. ls_field-min = iv_min. ls_field-max = iv_max. ls_field-password = iv_password. + ls_field-condense = iv_condense. ls_field-hint = iv_hint. ls_field-required = iv_required. ls_field-placeholder = iv_placeholder. diff --git a/src/ui/zcl_abapgit_html_form_utils.clas.abap b/src/ui/zcl_abapgit_html_form_utils.clas.abap index 5b102fb3d..0f4c992f7 100644 --- a/src/ui/zcl_abapgit_html_form_utils.clas.abap +++ b/src/ui/zcl_abapgit_html_form_utils.clas.abap @@ -59,7 +59,7 @@ ENDCLASS. -CLASS ZCL_ABAPGIT_HTML_FORM_UTILS IMPLEMENTATION. +CLASS zcl_abapgit_html_form_utils IMPLEMENTATION. METHOD constructor. @@ -169,6 +169,10 @@ CLASS ZCL_ABAPGIT_HTML_FORM_UTILS IMPLEMENTATION. LOOP AT lt_fields ASSIGNING WHERE type <> zif_abapgit_html_form=>c_field_type-field_group. CLEAR lv_value. lv_value = io_form_data->get( -name ). + IF -condense = abap_true. + lv_value = condense( val = lv_value + del = ` ` ). + ENDIF. IF -type = zif_abapgit_html_form=>c_field_type-checkbox. ro_form_data->set( @@ -241,6 +245,10 @@ CLASS ZCL_ABAPGIT_HTML_FORM_UTILS IMPLEMENTATION. lt_fields = mo_form->get_fields( ). LOOP AT lt_fields ASSIGNING . lv_value = io_form_data->get( -name ). + IF -condense = abap_true. + lv_value = condense( val = lv_value + del = ` ` ). + ENDIF. IF -required IS NOT INITIAL AND lv_value IS INITIAL. ro_validation_log->set( iv_key = -name diff --git a/src/ui/zif_abapgit_html_form.intf.abap b/src/ui/zif_abapgit_html_form.intf.abap index faf271ca6..2a42cb80c 100644 --- a/src/ui/zif_abapgit_html_form.intf.abap +++ b/src/ui/zif_abapgit_html_form.intf.abap @@ -26,6 +26,7 @@ INTERFACE zif_abapgit_html_form subitems TYPE ty_subitems, readonly TYPE abap_bool, password TYPE abap_bool, + condense TYPE abap_bool, min TYPE i, max TYPE i, END OF ty_field . diff --git a/src/utils/zcl_abapgit_url.clas.abap b/src/utils/zcl_abapgit_url.clas.abap index dcf682008..44e3b6f54 100644 --- a/src/utils/zcl_abapgit_url.clas.abap +++ b/src/utils/zcl_abapgit_url.clas.abap @@ -119,10 +119,10 @@ CLASS zcl_abapgit_url IMPLEMENTATION. METHOD regex. - FIND REGEX '(https?://[^/]*)(.*/)(.*)\.git$' IN iv_url + FIND REGEX '^(https?://[^/]*)(.*/)(.*)\.git$' IN iv_url SUBMATCHES ev_host ev_path ev_name. IF sy-subrc <> 0. - FIND REGEX '(https?://[^/]*)(.*/)(.*)$' IN iv_url + FIND REGEX '^(https?://[^/]*)(.*/)(.*)$' IN iv_url SUBMATCHES ev_host ev_path ev_name. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( 'Malformed URL' ). @@ -132,14 +132,6 @@ CLASS zcl_abapgit_url IMPLEMENTATION. ENDMETHOD. - METHOD validate. - - name( iv_url = iv_url - iv_validate = abap_true ). - - ENDMETHOD. - - METHOD url_address. DATA: @@ -167,4 +159,10 @@ CLASS zcl_abapgit_url IMPLEMENTATION. ENDMETHOD. + METHOD validate. + + name( iv_url = iv_url + iv_validate = abap_true ). + + ENDMETHOD. ENDCLASS.