#31214 closed defect (bug) (fixed)
oEmbed: Newlines within <pre> tags get removed
| Reported by: | cweiske | Owned by: | wonderboymusic |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.2 |
| Component: | Embeds | Version: | 4.1 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
Description
An oEmbed's HTML content gets all \n newlines removed through
add_filter( 'oembed_dataparse', array($this, '_strip_newlines'), 10, 3 );
WP_oEmbed::strip_newlines() unfortunately removes every newline, even those within <pre> tags - but they are crucial there. My oEmbedded code pastes all only have a single line currently: http://fotostore.cweiske.de/screenshots/2015-02-02%20wordpress%20oembed%20newlines.png
Please fix this method to not remove newlines within <pre> tags.
Attachments (2)
Change History (15)
#5
@
11 years ago
The applied patch does not work when the <pre> tag contains HTML entities like  .
$dom->saveHTML() replaces the entities with their real characters, which in turn leads to a failing following str_replace call.
Try to embedding http://p.cweiske.de/158 - it is what I have the problem with.
#7
@
11 years ago
I tried to use html_entity_decode on the input HTML and the saveHTML()'ed HTML, but it seems that the saved <pre> tag is UTF-8, while the input html is a different encoding.
#9
@
11 years ago
DOMDocumentis awesome and completely sucks at the same time- 31214.2.diff uses RegEx instead, please test.
#10
@
11 years ago
Thanks - this patch works fine.
http://fotostore.cweiske.de/screenshots/2015-02-11%20wordpress%20phorkie%20oembed%20fixed.png
#12
@
11 years ago
- Resolution → fixed
- Status reopened → closed
Calling this fixed - I have been filtering oembed responses for 3 weeks now and adding <pre> tags. All works as expected.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
31214.diff does this if
DOMDocumentexists, which falls in line with other places that bow out ifDOMDocumentisn't available (please don't disable this, for crying out loud).The tokens have to be sequential to account for HTML nodes that may be identical