Skip to content

Commit 0b52291

Browse files
committed
Fix handling for HTML entities
1 parent ebea6c6 commit 0b52291

File tree

2 files changed

+58
-3
lines changed

2 files changed

+58
-3
lines changed

src/zcl_htmldiff.clas.abap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ CLASS zcl_htmldiff DEFINITION
1717

1818
PUBLIC SECTION.
1919

20-
CONSTANTS c_version TYPE string VALUE '1.0.0' ##NEEDED.
20+
CONSTANTS c_version TYPE string VALUE '1.0.1' ##NEEDED.
2121

2222
INTERFACES zif_htmldiff.
2323

@@ -762,8 +762,8 @@ CLASS zcl_htmldiff IMPLEMENTATION.
762762

763763
METHOD is_character.
764764

765-
" Alphanumeric characters (includes underscore)
766-
FIND REGEX '[\w]' IN iv_input.
765+
" Alphanumeric characters (includes underscore) plus characters to identify HTML symbol entities
766+
FIND REGEX '[\w&#;]' IN iv_input.
767767

768768
rv_result = xsdbool( sy-subrc = 0 ).
769769

src/zcl_htmldiff.clas.testclasses.abap

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,3 +1208,58 @@ CLASS ltcl_render_operations IMPLEMENTATION.
12081208
ENDMETHOD.
12091209

12101210
ENDCLASS.
1211+
1212+
************************************************************************
1213+
* Tests for ABAP implementation
1214+
************************************************************************
1215+
1216+
CLASS ltcl_htmldiff_test_3 DEFINITION FOR TESTING
1217+
DURATION SHORT
1218+
RISK LEVEL HARMLESS.
1219+
1220+
PRIVATE SECTION.
1221+
1222+
METHODS:
1223+
html_symbol_entities FOR TESTING,
1224+
tags_and_entities FOR TESTING.
1225+
1226+
ENDCLASS.
1227+
1228+
CLASS ltcl_htmldiff_test_3 IMPLEMENTATION.
1229+
1230+
METHOD html_symbol_entities.
1231+
1232+
DATA:
1233+
lv_act TYPE string,
1234+
lv_exp TYPE string.
1235+
1236+
lv_act = lcl_helper=>htmldiff(
1237+
iv_before = 'a < c'
1238+
iv_after = 'a > c' ).
1239+
1240+
lv_exp = 'a <del>&lt;</del><ins>&gt;</ins> c'.
1241+
1242+
cl_abap_unit_assert=>assert_equals(
1243+
act = lv_act
1244+
exp = lv_exp ).
1245+
1246+
ENDMETHOD.
1247+
1248+
METHOD tags_and_entities.
1249+
1250+
DATA:
1251+
lv_act TYPE string,
1252+
lv_exp TYPE string.
1253+
1254+
lv_act = lcl_helper=>htmldiff(
1255+
iv_before = '&lt;ls_var&gt;'
1256+
iv_after = '<span class="keyword">FIELD-SYMBOL</span>(&lt;ls_var&gt;)' ).
1257+
1258+
lv_exp = '<span class="keyword"><ins>FIELD-SYMBOL</ins></span><ins>(</ins>&lt;ls_var&gt;<ins>)</ins>'.
1259+
1260+
cl_abap_unit_assert=>assert_equals(
1261+
act = lv_act
1262+
exp = lv_exp ).
1263+
1264+
ENDMETHOD.
1265+
ENDCLASS.

0 commit comments

Comments
 (0)