fix: Invalid scheme check in Attr.TargetBlank#363
Merged
ezyang merged 1 commit intoezyang:masterfrom Jan 27, 2023
jstanden:jstanden-patch-1
Merged
fix: Invalid scheme check in Attr.TargetBlank#363ezyang merged 1 commit intoezyang:masterfrom jstanden:jstanden-patch-1
ezyang merged 1 commit intoezyang:masterfrom
jstanden:jstanden-patch-1
Conversation
When `Attr.TargetBlank` is enabled, a PHP warning is logged if an `href` attribute contains an invalid URI scheme. Normally an `href` like `javascript:void(0)` or `itms-apps://itunes.apple.com/developer/id1234567890` would be removed by the default `HTMLPurifier_Config` configuration. However, it's possible to insert a URL with an unknown context from a trusted source after filtering. For instance, an `HTMLPurifier_URIFilter` extension. This patch doesn't change any functionality or permit anything new, it simply adds error checking around `$url->getSchemeObj()` which returns `HTMLPurifier_URIScheme|false`. The `false` case is currently not handled, resulting in error log entries under PHP 8.x like the following: ~~~ Attempt to read property "browsable" on bool /PATH/TO/APP/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/TargetBlank.php:L38 ~~~
ezyang
approved these changes
Jan 27, 2023
github-actions Bot
pushed a commit
that referenced
this pull request
Nov 17, 2023
# [4.17.0](v4.16.0...v4.17.0) (2023-11-17) ### Bug Fixes * CSSTidy ImportantComments not handled properly ([#359](#359)) ([78a9b4d](78a9b4d)) * fix CI ([#361](#361)) ([9ec687c](9ec687c)) * Invalid scheme check in Attr.TargetBlank ([#363](#363)) ([0176ef4](0176ef4)) * semantic release ([#339](#339)) ([d82f3d9](d82f3d9)) * semantic release ([#341](#341)) ([e55fead](e55fead)), closes [#339](#339) * Support for locales using decimal separators other than . (dot) ([#372](#372)) ([43f49ac](43f49ac)) ### Features * Add support for all text-decoration properties ([#360](#360)) ([2d775c0](2d775c0)) * Allows commas to be included in tel URI ([#389](#389)) ([ec92490](ec92490)), closes [#388](#388) ### Reverts * Revert "fix: semantic release (#339)" (#340) ([3e83215](3e83215)), closes [#339](#339) [#340](#340)
|
🎉 This PR is included in version 4.17.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
Attr.TargetBlankis enabled, a PHP warning is logged if anhrefattribute contains an invalid URI scheme.Normally an
hreflikejavascript:void(0)oritms-apps://itunes.apple.com/developer/id1234567890would be removed by the defaultHTMLPurifier_Configconfiguration.However, it's possible to insert a URL with an unknown context from a trusted source after filtering. For instance, an
HTMLPurifier_URIFilterextension.This patch doesn't change any functionality or permit anything new, it simply adds error checking around
$url->getSchemeObj()which returnsHTMLPurifier_URIScheme|false.The
falsecase is currently not handled, resulting in error log entries under PHP 8.x like the following: