Skip to content

Commit

Permalink
[SECURITY] Properly escape content
Browse files Browse the repository at this point in the history
  • Loading branch information
brotkrueml committed Jun 13, 2022
1 parent cf09217 commit 550835b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Security
- Properly escape content

## [2.5.0] - 2022-05-18

### Added
Expand Down
2 changes: 1 addition & 1 deletion Classes/JsonLd/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function render(): string

return \sprintf(
Extension::JSONLD_TEMPLATE,
\json_encode($result, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE)
\json_encode($result, \JSON_HEX_TAG | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE)
);
}

Expand Down
6 changes: 6 additions & 0 deletions Documentation/Changelog/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`_.
`Unreleased <https://github.com/brotkrueml/schema/compare/v2.5.0...HEAD>`_
------------------------------------------------------------------------------

Security
^^^^^^^^


* Properly escape content

`2.5.0 <https://github.com/brotkrueml/schema/compare/v2.4.0...v2.5.0>`_ - 2022-05-18
----------------------------------------------------------------------------------------

Expand Down
8 changes: 8 additions & 0 deletions Tests/Unit/JsonLd/RendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ public function dataProvider(): \Iterator
],
'{"@context":"https://schema.org/","@type":"GenericStub","some-property":{"@id":"some-node-identifier-id"}}',
];

yield 'Value is a string provoking XSS' => [
null,
[
'some-string' => '</script><svg/onload=prompt(document.domain)>',
],
'{"@context":"https://schema.org/","@type":"GenericStub","some-string":"\u003C/script\u003E\u003Csvg/onload=prompt(document.domain)\u003E"}',
];
}

/**
Expand Down

0 comments on commit 550835b

Please sign in to comment.