Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Invalid scheme check in Attr.TargetBlank #363

Merged
merged 1 commit into from
Jan 27, 2023
Merged

fix: Invalid scheme check in Attr.TargetBlank #363

merged 1 commit into from
Jan 27, 2023

Commits on Jan 26, 2023

  1. fix: Invalid scheme check in Attr.TargetBlank

    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
    ~~~
    jstanden committed Jan 26, 2023
    Configuration menu
    Copy the full SHA
    8e66aa1 View commit details
    Browse the repository at this point in the history