#31214 closed defect (bug) (fixed)
oEmbed: Newlines within <pre> tags get removed
Reported by: | cweiske | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | 4.2 | Priority: | normal |
Severity: | normal | Version: | 4.1 |
Component: | Embeds | Keywords: | has-patch |
Focuses: | Cc: |
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)
#1
@
10 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to Future Release
#2
@
10 years ago
- Keywords has-patch added; needs-patch removed
- Milestone changed from Future Release to 4.2
#3
@
10 years ago
- Owner set to wonderboymusic
- Resolution set to fixed
- Status changed from new to closed
In 31415:
#5
@
10 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 embed http://p.cweiske.de/158 - it is what I have the problem with.
#7
@
10 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
@
10 years ago
DOMDocument
is awesome and completely sucks at the same time- 31214.2.diff uses RegEx instead, please test.
#10
@
10 years ago
Thanks - this patch works fine.
http://fotostore.cweiske.de/screenshots/2015-02-11%20wordpress%20phorkie%20oembed%20fixed.png
#12
@
10 years ago
- Resolution set to fixed
- Status changed from reopened to closed
Calling this fixed - I have been filtering oembed responses for 3 weeks now and adding <pre>
tags. All works as expected.
31214.diff does this if
DOMDocument
exists, which falls in line with other places that bow out ifDOMDocument
isn'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