Skip to content

Commit

Permalink
Decode HTML entities in URLs from src attributes (#558)
Browse files Browse the repository at this point in the history
Fixes #559.

- Decode HTML entities in URLs extracted from HTML src attributes.
  • Loading branch information
kasparsd authored and kevinfodness committed Sep 18, 2018
1 parent c0c86db commit d8b7166
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions includes/apple-exporter/class-exporter-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public static function format_src_url( $url ) {
$url = site_url( $url );
}

// Decode the HTML entities since the URL is from the src attribute.
$url = html_entity_decode( $url );

// Escape the URL and ensure it is valid.
$url = esc_url_raw( $url );
if ( empty( $url ) ) {
Expand Down
11 changes: 10 additions & 1 deletion tests/apple-exporter/test-class-exporter-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,14 @@ public function testCompleteContent() {
$this->assertEquals( 'someurl.com', $content->cover() );
}

}
/**
* Ensure we decode the HTML entities in URLs extracted from HTML attributes.[type]
*/
public function test_format_src_url() {
$this->assertEquals(
'https://example.com/some.mp3?one=two&query=arg',
\Apple_Exporter\Exporter_Content::format_src_url( 'https://example.com/some.mp3?one=two&query=arg' )
);
}

}

0 comments on commit d8b7166

Please sign in to comment.