Make WordPress Core

Opened 17 years ago

Closed 17 years ago

#3621 closed defect (bug) (fixed)

wpautop() should not break up script and object tags

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


Make a post with this:

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

Results in this:

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

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 17 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
17 years ago

Another example:


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

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

#2 @Viper007Bond
17 years ago


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

#3 @Viper007Bond
17 years ago

See also: #3476

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

#4 @foolswisdom
17 years ago

Another duplicate is #3679

#5 @foolswisdom
17 years ago

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

17 years ago

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

#6 @mm6
17 years ago

New output with wpautop_dont_break_script_object.patch:


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


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

#7 follow-up: @mm6
17 years ago

  • Keywords has-patch added; needs-patch removed

#8 in reply to: ↑ 7 @dllmain
17 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);


$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
17 years ago

  • Milestone changed from 2.2 to 2.3

#10 @Otto42
17 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
17 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
17 years ago

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

#13 @Otto42
17 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
17 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.