html: add guard for max indentation (#6587)

Co-authored-by: Marc Bernard <59966492+mbtools@users.noreply.github.com>
This commit is contained in:
Lars Hvam 2023-10-27 17:30:55 +02:00 committed by GitHub
parent 7bdd8f9f4c
commit e1aa0e733f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 6 deletions

View File

@ -32,6 +32,8 @@ CLASS zcl_abapgit_html DEFINITION
PROTECTED SECTION.
PRIVATE SECTION.
CONSTANTS c_max_indent TYPE i VALUE 200.
TYPES:
BEGIN OF ty_indent_context,
no_indent_jscss TYPE abap_bool,
@ -107,7 +109,7 @@ CLASS zcl_abapgit_html IMPLEMENTATION.
gv_spaces = repeat(
val = ` `
occ = 200 ).
occ = c_max_indent ).
GET PARAMETER ID 'DBT' FIELD lv_mode.
gv_debug_mode = boolc( lv_mode = 'HREF' ).
@ -189,7 +191,11 @@ CLASS zcl_abapgit_html IMPLEMENTATION.
OR ls_study-tag_close = abap_true )
AND cs_context-indent > 0.
lv_spaces = ( cs_context-indent - 1 ) * c_indent_size.
cv_line = gv_spaces(lv_spaces) && cv_line.
IF lv_spaces <= c_max_indent.
cv_line = gv_spaces(lv_spaces) && cv_line.
ELSE.
cv_line = gv_spaces && cv_line.
ENDIF.
ELSE.
cv_line = cs_context-indent_str && cv_line.
ENDIF.
@ -216,7 +222,11 @@ CLASS zcl_abapgit_html IMPLEMENTATION.
cs_context-indent = cs_context-indent - 1.
ENDIF.
lv_spaces = cs_context-indent * c_indent_size.
cs_context-indent_str = gv_spaces(lv_spaces).
IF lv_spaces <= c_max_indent.
cs_context-indent_str = gv_spaces(lv_spaces).
ELSE.
cv_line = gv_spaces && cv_line.
ENDIF.
ENDIF.
ENDMETHOD.
@ -371,10 +381,10 @@ CLASS zcl_abapgit_html IMPLEMENTATION.
METHOD zif_abapgit_html~add.
DATA: lv_type TYPE c,
DATA: lv_type TYPE c,
li_renderable TYPE REF TO zif_abapgit_gui_renderable,
lx_error TYPE REF TO zcx_abapgit_exception,
lo_html TYPE REF TO zcl_abapgit_html.
lx_error TYPE REF TO zcx_abapgit_exception,
lo_html TYPE REF TO zcl_abapgit_html.
FIELD-SYMBOLS: <lt_tab> TYPE string_table.

View File

@ -33,6 +33,7 @@ CLASS ltcl_html DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
indent2 FOR TESTING RAISING zcx_abapgit_exception,
indent3 FOR TESTING RAISING zcx_abapgit_exception,
indent4 FOR TESTING RAISING zcx_abapgit_exception,
indent5 FOR TESTING RAISING zcx_abapgit_exception,
style1 FOR TESTING RAISING zcx_abapgit_exception.
METHODS:
@ -119,6 +120,16 @@ CLASS ltcl_html IMPLEMENTATION.
ENDMETHOD.
METHOD indent5.
* dont dump if something messes up or the nesting gets too wide
DO 300 TIMES.
mo_html->add( '<td>' ).
ENDDO.
mo_html->render( ).
ENDMETHOD.
METHOD style1.
DATA lv_exp TYPE string.