Bug 487978 - Shell syntax highlighting does not handle escaped line breaks properly
Summary: Shell syntax highlighting does not handle escaped line breaks properly
Status: RESOLVED FIXED
Alias: None
Product: frameworks-syntax-highlighting
Classification: Frameworks and Libraries
Component: syntax (show other bugs)
Version: unspecified
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-03 17:49 UTC by Allen Webb
Modified: 2024-08-22 15:54 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
shell file that demonstrates highlighting issue when opened in kate (251 bytes, text/x-sh)
2024-06-03 17:49 UTC, Allen Webb
Details
Screenshot that includes both the observed behavior and the kate version information. (158.26 KB, image/png)
2024-06-03 17:50 UTC, Allen Webb
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Allen Webb 2024-06-03 17:49:24 UTC
Created attachment 170102 [details]
shell file that demonstrates highlighting issue when opened in kate

***
If you're not sure this is actually a bug, instead post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***

SUMMARY
I have attached an example shell file for which syntax highlighting is broken, but the shell is valid.

Note the breakage seems to occur because of an escaped line break inside a conditional statement causing a leading double quote that appears to be escaped instead of the end of line.

STEPS TO REPRODUCE
1. Open the attached example in Kate or Kwrite
2. Observe the syntax highlighting

OBSERVED RESULT
The start of the string in the second half of the conditional appears to be escaped leading to incorrect syntax highlighting for the rest of the file.

EXPECTED RESULT
The escape character should be applied to the end-of-line instead of the double quote.

SOFTWARE/OS VERSIONS
Tested with Kate 23.08.1 on a custom distro. I can try again on Kubuntu 24.04 when I get home.

ADDITIONAL INFORMATION
Comment 1 Allen Webb 2024-06-03 17:50:32 UTC
Created attachment 170104 [details]
Screenshot that includes both the observed behavior and the kate version information.
Comment 2 Allen Webb 2024-06-07 01:18:13 UTC
It reproduces on Kate 23.08.5
Comment 3 Bug Janitor Service 2024-08-21 22:16:20 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/syntax-highlighting/-/merge_requests/652
Comment 4 Christoph Cullmann 2024-08-22 15:54:53 UTC
Git commit 1395988e39b59c8734e0291578fa9d6f98e160e8 by Christoph Cullmann, on behalf of Jonathan Poelen.
Committed on 22/08/2024 at 15:52.
Pushed by cullmann into branch 'master'.

Bash: fix escaped line in brace condition

M  +10   -0    autotests/folding/highlight.sh.fold
M  +10   -0    autotests/html/highlight.sh.dark.html
M  +10   -0    autotests/html/highlight.sh.html
M  +10   -0    autotests/input/highlight.sh
M  +10   -0    autotests/reference/highlight.sh.ref
M  +23   -7    data/syntax/bash.xml

https://invent.kde.org/frameworks/syntax-highlighting/-/commit/1395988e39b59c8734e0291578fa9d6f98e160e8