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

Temporarily suspend PHP Warnings on invalid tags #82

Merged
Merged
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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@

## [Unreleased]

* Temporarily suspend PHP Warnings on invalid tags when processing Gist HTML ([#81](https://github.com/bradyvercher/gistpress/issues/81))

## [v3.0.2] - 2020-01-16

* Sanitized the `id` attribute passed to the `[gist]` shortcode. This fixes an XSS vulnerability that could be exploited by untrusted contributors on multi-author sites. Thanks to [@cornerpirate](https://github.com/cornerpirate) for disclosing responsibly.
7 changes: 7 additions & 0 deletions includes/class-gistpress.php
Original file line number Diff line number Diff line change
@@ -463,6 +463,10 @@ public function process_gist_html( $html, array $args ) {
$html = '<?xml encoding="utf-8" ?>' . $html;

$dom = new DOMDocument();

// Temporarily suppress warnings for invalid tags.
$previous_libxml_use_internal_errors_value = libxml_use_internal_errors( true );

$dom->loadHTML( $html, LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED );

$lines = $dom->getElementsByTagName( 'tr' );
@@ -537,6 +541,9 @@ public function process_gist_html( $html, array $args ) {
$html = $this->process_gist_line_numbers( $html, $args['lines'], $args['lines_start'] );
}

// Reset to previous value.
libxml_use_internal_errors( $previous_libxml_use_internal_errors_value );

return $html;
}