Make WordPress Core

Opened 15 years ago

Last modified 5 years ago

#10033 new defect (bug)

wpautop problems with html comments and object tags

Reported by: denis-de-bernardy's profile Denis-de-Bernardy Owned by:
Milestone: Priority: normal
Severity: minor Version: 2.8
Component: Formatting Keywords: wpautop needs-unit-tests
Focuses: Cc:

Description

Bumped into this one when upgrading my mediacaster plugin to use swfobject 2.1 (which is not 1.5 compatible), as documented here:

http://code.google.com/p/swfobject/wiki/documentation

I take it I'm not the only one who is going to need to upgrade a plugin. It's minor, since I'll just move the filter further down in the queue, but it's still worth reporting:

<object id="m544cf9700db147f751dc34ea1241d8bd" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="320" height="260">
<param name="movie" value="http://www.youtube.com/v/_nkZ3eHeXlc" />
<!--[if !IE]>-->

<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/_nkZ3eHeXlc" width="320" height="260">
<!--<![endif]-->
<p><a href="http://www.macromedia.com/go/getflashplayer">Get Flash 9.0</a> to see this player.</p>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
<script type="text/javascript">
//swfobject.registerObject("m544cf9700db147f751dc34ea1241d8bd", "9.0.0");
</script>

Gets turned into the following mess:

<object id="m544cf9700db147f751dc34ea1241d8bd" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="320" height="260"><param name="movie" value="http://www.youtube.com/v/_nkZ3eHeXlc" /><!--[if !IE]>&#8211;><br />
<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/_nkZ3eHeXlc" width="320" height="260"><br />
<!--<![endif]--></p>
<p><a href="http://www.macromedia.com/go/getflashplayer">Get Flash 9.0</a> to see this player.</p>
<p><!--[if !IE]>&#8211;><br />
</object><br />

<!--<![endif]--><br />
</object><br />
<script type="text/javascript">
//swfobject.registerObject("m544cf9700db147f751dc34ea1241d8bd", "9.0.0");
</script>

So, two/three issues:

  • wpautop should also ignore double object tags, and html comments
  • wptexturize should ignore html comments

Change History (14)

#1 @markjaquith
15 years ago

  • Milestone changed from 2.9 to 3.0

No patch. Does someone want to take a look at this for WP 3.0?

#2 @Viper007Bond
15 years ago

  • Keywords needs-patch added

Bumpy bump! I'd greatly appreciate this being fixed as I'm moving my video plugin over to using this type of embedding.

Not sure if I'm good enough with regex to make a patch myself though.

#3 @Viper007Bond
15 years ago

The wpautop() issue could also affect normal embeds (i.e. oEmbed).

#4 @rmccue
15 years ago

Related: #8912

#5 @ryan
14 years ago

  • Milestone changed from 3.0 to 3.1

#6 follow-up: @azaozz
14 years ago

For wpautop the fix is to ensure that there aren't any line breaks inside the <object> tag. There is a regex in it that tries to remove them (in both the php and JS versions) but it is not HTML comments aware.

The above example breaks because the IE conditionals are on new lines. We could add yet another regex to specifically check for HTML comments but it's generally better for plugins to remove any line breaks from complex <object> blocks when inserting them before wpautop (this is true for all complex HTML blocks too). The objects inserted by WordPress work properly.

#7 @nacin
14 years ago

  • Milestone changed from Awaiting Triage to Future Release

#8 follow-up: @norbertm
14 years ago

  • Cc norbert@… added

The wptexturize part will be fixed to skip HTML tags in #4539.

#9 in reply to: ↑ 8 @norbertm
14 years ago

Replying to norbertm:

The wptexturize part will be fixed to skip HTML tags in #4539.

Including test cases with #4539, specifically for the <!--[if !IE]>--> and <!--<![endif]--> sections.

#10 @nacin
11 years ago

  • Keywords wptexturize added

#11 @nacin
11 years ago

  • Keywords wpautop added

#12 @miqrogroove
10 years ago

  • Keywords wptexturize removed
  • Summary changed from wptexturize and wpautop problems with html comments and object tags to wpautop problems with html comments and object tags

See #8912 for wptexturize.

#13 in reply to: ↑ 6 @ericlewis
10 years ago

Replying to azaozz:

We could add yet another regex to specifically check for HTML comments

We could add a regex to get rid of any new lines within <object>s?

#14 @miqrogroove
9 years ago

  • Keywords needs-unit-tests added; needs-patch removed

Most of these issues should be resolved by 4.3.1 and earlier updates. Let's try to add relevant tests and see what's remaining to be fixed.

Note: See TracTickets for help on using tickets.