WordPress.org

Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#3621 closed defect (bug) (fixed)

wpautop() should not break up script and object tags

Reported by: Viper007Bond Owned by:
Milestone: 2.2 Priority: normal
Severity: normal Version: 2.1
Component: General Keywords: has-patch
Focuses: Cc:

Description

Make a post with this:

Test<object><param name="text" value="test" /></object>test

Results in this:

<p>Test<br />
<object>
<param name="text" value="test" /></object>
<p>test</p>

The <br /> probably shouldn't be there, there shouldn't be a line break after the <object>, and most importantly, there's a missing </p>.

Attachments (1)

wpautop_dont_break_script_object.patch (1.3 KB) - added by mm6 10 years ago.
patch to make wpautop() not put line breaks before and after object and script tags

Download all attachments as: .zip

Change History (15)

#1 @Viper007Bond
10 years ago

Another example:

Test

<span>Test</span><script type="text/javascript">/* Test */</script>

Test
p>Test</p>
<p><span>Test</span><br />
<script type="text/javascript">/* Test */</script>
<p>Test</p>

#2 @Viper007Bond
10 years ago

Er...

<p>Test</p>
<p><span>Test</span><br />
<script type="text/javascript">/* Test */</script>
<p>Test</p>

#3 @Viper007Bond
10 years ago

See also: #3476

(Forgot I already made a ticket on this quite a while back.)

#4 @foolswisdom
10 years ago

Another duplicate is #3679

#5 @foolswisdom
10 years ago

  • Summary changed from More fun with wpautop() to wpautop() should not break up script and object tags

@mm6
10 years ago

patch to make wpautop() not put line breaks before and after object and script tags

#6 @mm6
10 years ago

New output with wpautop_dont_break_script_object.patch:

In:

Test<object><param name="text" value="test" /></object>test

Out:

<p>Test<object>
<param name="text" value="test" /></object>test</p>

#7 follow-up: @mm6
10 years ago

  • Keywords has-patch added; needs-patch removed

#8 in reply to: ↑ 7 @dllmain
10 years ago

I had trouble with broken object tags in 2.1.2, too.
I fixed this in another way that at least worked with
raw posts from phpMyAdmin.
I changed line 75 of formatting.php from

$pee = preg_replace('/<(script|style).*?<\/\\1>/se', 'str_replace("\n", "<WPPreserveNewline />", "\\0")', $pee);

to

$pee = preg_replace('/<(object|script|style).*?<\/\\1>/se', 'str_replace("\n", "<WPPreserveNewline />", "\\0")', $pee);

I have no idea what that code actually is doing - just though I should share this.
Would be great if you could save me patching this in future releases.

#9 @foolswisdom
10 years ago

  • Milestone changed from 2.2 to 2.3

#10 @Otto42
10 years ago

It would be nice if we could get dllmain's patch into 2.2 for another reason. That bit of code prevents it from converting newlines into BR's inside script and style blocks. By adding object blocks to that, it would eliminate a lot of the issues people have with pasting in the object codes given out from sites like youtube and such.

#11 @foolswisdom
10 years ago

  • Milestone changed from 2.3 to 2.2

Otto42, do you currently run with this patch installed? I will install it now on my live blog as well.

#12 @foolswisdom
10 years ago

How does this relate to the issue and fix in #3854?

#13 @Otto42
10 years ago

With this patch? No.

With the adjustment given in dllmain's comment above, yes.

I have not analyzed the diff attached to this ticket, but I have made the same core hack that dllmain describes in his comment above, for probably the same reasons he did.

#14 @rob1n
10 years ago

  • Resolution set to fixed
  • Status changed from new to closed

This was fixed in [5262]. I can't reproduce anymore in r5269.

Note: See TracTickets for help on using tickets.