Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Transformers/StringTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public function transform($value): string

protected function escape(string $value): string
{
return str_replace(['\\', "'", "\r", "\n"], ['\\\\', "\'", '\\r', '\\n'], $value);
return str_replace(['\\', "'", "\r", "\n", '<', '>'], ['\\\\', "\'", '\\r', '\\n', '\<', '\>'], $value);
}
}
11 changes: 11 additions & 0 deletions tests/BladeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ public function it_can_render_a_numeric_string_as_a_string()
);
}

/** @test */
public function it_escapes_tags_in_a_string()
{
$parameter = ['string' => "This is a <tag>"];

$this->assertEquals(
'<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'string\'] = \'This is a \<tag\>\';</script>',
$this->renderView('variable', compact('parameter'))
);
}

/** @test */
public function it_can_render_arrayable_objects()
{
Expand Down