major
minor
major
minor
minor
#26557
TL-Doc: Highlighting of code blocks leads to RegEx errors
In the deployed TL-Doc, pages containing code blocks are not displayed correctly:
The following message appears in the developer console:
top-logic.js?t=1647243919167:37472 Uncaught SyntaxError: Invalid regular expression: /\$+[a-zA-Z_�-??][a-zA-Z0-9_�-??]*/: Range out of order in character class
at new RegExp (<anonymous>)
at t (top-logic.js?t=1647243919167:37472:1988)
at r (top-logic.js?t=1647243919167:37472:2427)
at top-logic.js?t=1647243919167:37472:2721
at Array.forEach (<anonymous>)
at r (top-logic.js?t=1647243919167:37472:2701)
at l (top-logic.js?t=1647243919167:37472:2923)
at f (top-logic.js?t=1647243919167:37472:4595)
at top-logic.js?t=1647243919167:37472:5100
at Array.forEach (<anonymous>)
If you switch to edit mode and back again (regardless of whether changes were made), the highlighting works again. The error can be reproduced by clearing the cache and reloading the page.
On such “broken” pages, clicking on TLObject links also causes the page to reload.
Fix
The problem arises from encoding issues when the JS files are merged into a single file during deployment. This does not happen with a new version of highlight.js. Therefore, it was updated to version 11.5.0 and also implemented with Maven dependencies (https://mvnrepository.com/artifact/org.webjars/highlightjs/11.5.0).
Test
Before testing, set `original-names` to `false` in `/com.top_logic/src/main/webapp/WEB-INF/conf/enable-debug.config.xml`:
<config service-class="com.top_logic.gui.JSFileCompiler">
<instance
always-check="true"
original-names="false"
/>
</config>
Then start the application and open a TL-Doc page that contains at least two code blocks. The code blocks must be formatted correctly—that is, they must have a background color and, where applicable, different highlighting for variables, functions, etc. Additionally, no errors should be logged in the developer console. Also clear the cache and check whether the blocks are still displayed correctly.