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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions includes/class-gistpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -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;
}

Expand Down