Skip to content

Commit

Permalink
[BUGFIX] Limit inline variables to Alphanumeric + Underscore
Browse files Browse the repository at this point in the history
Other variable names are not possible and this prevents so many false positives in texts with pipes.
  • Loading branch information
linawolf committed Dec 10, 2023
1 parent 772dac5 commit ca4a631
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,15 @@ public function apply(BlockContext $blockContext, InlineLexer $lexer): InlineNod

return new VariableInlineNode($text);

default:
case $token->type === InlineLexer::WORD:
case $token->type === InlineLexer::UNDERSCORE:
$text .= $token->value;
break;

default:
$this->rollback($lexer, $initialPosition ?? 0);

return null;
}

if ($lexer->moveNext() === false && $lexer->token === null) {
Expand Down
8 changes: 8 additions & 0 deletions tests/Integration/tests/text-with-pipe/expected/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- content start -->
<div class="section" id="some-title">
<h1>Some Title</h1>

<p>string | array | object</p>
</div>

<!-- content end -->
4 changes: 4 additions & 0 deletions tests/Integration/tests/text-with-pipe/input/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Some Title
==========

string | array | object

0 comments on commit ca4a631

Please sign in to comment.