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. PROTECTED SECTION.
PRIVATE SECTION. PRIVATE SECTION.
CONSTANTS c_max_indent TYPE i VALUE 200.
TYPES: TYPES:
BEGIN OF ty_indent_context, BEGIN OF ty_indent_context,
no_indent_jscss TYPE abap_bool, no_indent_jscss TYPE abap_bool,
@ -107,7 +109,7 @@ CLASS zcl_abapgit_html IMPLEMENTATION.
gv_spaces = repeat( gv_spaces = repeat(
val = ` ` val = ` `
occ = 200 ). occ = c_max_indent ).
GET PARAMETER ID 'DBT' FIELD lv_mode. GET PARAMETER ID 'DBT' FIELD lv_mode.
gv_debug_mode = boolc( lv_mode = 'HREF' ). gv_debug_mode = boolc( lv_mode = 'HREF' ).
@ -189,7 +191,11 @@ CLASS zcl_abapgit_html IMPLEMENTATION.
OR ls_study-tag_close = abap_true ) OR ls_study-tag_close = abap_true )
AND cs_context-indent > 0. AND cs_context-indent > 0.
lv_spaces = ( cs_context-indent - 1 ) * c_indent_size. lv_spaces = ( cs_context-indent - 1 ) * c_indent_size.
IF lv_spaces <= c_max_indent.
cv_line = gv_spaces(lv_spaces) && cv_line. cv_line = gv_spaces(lv_spaces) && cv_line.
ELSE.
cv_line = gv_spaces && cv_line.
ENDIF.
ELSE. ELSE.
cv_line = cs_context-indent_str && cv_line. cv_line = cs_context-indent_str && cv_line.
ENDIF. ENDIF.
@ -216,7 +222,11 @@ CLASS zcl_abapgit_html IMPLEMENTATION.
cs_context-indent = cs_context-indent - 1. cs_context-indent = cs_context-indent - 1.
ENDIF. ENDIF.
lv_spaces = cs_context-indent * c_indent_size. lv_spaces = cs_context-indent * c_indent_size.
IF lv_spaces <= c_max_indent.
cs_context-indent_str = gv_spaces(lv_spaces). cs_context-indent_str = gv_spaces(lv_spaces).
ELSE.
cv_line = gv_spaces && cv_line.
ENDIF.
ENDIF. ENDIF.
ENDMETHOD. ENDMETHOD.

View File

@ -33,6 +33,7 @@ CLASS ltcl_html DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
indent2 FOR TESTING RAISING zcx_abapgit_exception, indent2 FOR TESTING RAISING zcx_abapgit_exception,
indent3 FOR TESTING RAISING zcx_abapgit_exception, indent3 FOR TESTING RAISING zcx_abapgit_exception,
indent4 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. style1 FOR TESTING RAISING zcx_abapgit_exception.
METHODS: METHODS:
@ -119,6 +120,16 @@ CLASS ltcl_html IMPLEMENTATION.
ENDMETHOD. 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. METHOD style1.
DATA lv_exp TYPE string. DATA lv_exp TYPE string.