D17891: WML: fix infinite loop in contexts switch & only highlight tags with valid names

Nibaldo González noreply at phabricator.kde.org
Mon Dec 31 20:03:18 GMT 2018


nibags created this revision.
nibags added reviewers: Framework: Syntax Highlighting, dhaumann, cullmann.
Herald added projects: Kate, Frameworks.
Herald added subscribers: kde-frameworks-devel, kwrite-devel.
nibags requested review of this revision.

REVISION SUMMARY
  BUG: 402720
  
  In the `wml.xml` file an infinite context switch between `section` and `error` is generated, through `lineEndContext`: in a line break, the `section` context sends to `error` and then this is #poped in the line break, causing an infinite cycle. This causes that Kate freezes.
  
  This is reproducible by typing the `[` character and then a line break.
  
  This bug is reproducible only in KSyntaxHighlighting, since in KF5.48 there is no problem. It's probably necessary to add a guard that avoids infinite context changes.
  
  Also, the WML highlighter is a little old and I have seen some problems in sample files. The highlighter considers all content between `[` and `]` as tag. According to the documentation [1]:
  
    Also, tag and key names follow a special format. They will contain only alphanumeric characters and underscores; in particular, they will not contain +, -, or whitespace.
  
  Considering this, and based on the VSCode highlighter, I modified the code so that only tags with valid names are highlighted.
  
  **References:**
  
  - [1] Wesnoth Wiki. SyntaxWML, Tag and Attribute Structures: https://wiki.wesnoth.org/SyntaxWML#Tag_and_Attribute_Structures
  - [2] Wesnoth Markup Language syntax highlightning for VS Code: https://github.com/Byteron/wml , https://marketplace.visualstudio.com/items?itemName=Bitron.wml

REPOSITORY
  R216 Syntax Highlighting

BRANCH
  fix-wml

REVISION DETAIL
  https://phabricator.kde.org/D17891

AFFECTED FILES
  autotests/folding/test.pbl.fold
  autotests/html/test.pbl.html
  autotests/input/test.pbl
  autotests/reference/test.pbl.ref
  data/syntax/wml.xml

To: nibags, #framework_syntax_highlighting, dhaumann, cullmann
Cc: kwrite-devel, kde-frameworks-devel, hase, michaelh, ngraham, bruns, demsking, cullmann, sars, dhaumann
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kwrite-devel/attachments/20181231/be9049a7/attachment-0001.html>


More information about the KWrite-Devel mailing list