Skip to content

Commit

Permalink
surround: Fix unbalanced surround handling
Browse files Browse the repository at this point in the history
We should skip surround handling if we don't find the ending surround
part.

Fixes #17 (comment)
  • Loading branch information
karlb committed Feb 2, 2025
1 parent 4789e62 commit 4fe5afa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions smu.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,9 @@ dosurround(const char *begin, const char *end, int newblock) {
stop = p;
p = strstr(p + 1, surround[i].search);
} while (p && p[-1] == '\\');
if (p && p[-1] != '\\')
stop = p;
if (!p || p[-1] == '\\') /* No unescaped closing marker found */
continue;
stop = p;
if (!stop || stop < start || stop >= end)
continue;
fputs(surround[i].before, stdout);
Expand Down
1 change: 1 addition & 0 deletions tests/surround.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>hello_world</p>
1 change: 1 addition & 0 deletions tests/surround.text
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello_world

0 comments on commit 4fe5afa

Please sign in to comment.