WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 3 months ago

#10033 new defect (bug)

wptexturize and wpautop problems with html comments and object tags

Reported by: Denis-de-Bernardy Owned by:
Milestone: Future Release Priority: normal
Severity: minor Version: 2.8
Component: Formatting Keywords: needs-patch wptexturize wpautop
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 (11)

comment:1 markjaquith4 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?

comment:2 Viper007Bond4 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.

comment:3 Viper007Bond4 years ago

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

comment:4 rmccue4 years ago

Related: #8912

comment:5 ryan4 years ago

  • Milestone changed from 3.0 to 3.1

comment:6 azaozz4 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.

comment:7 nacin3 years ago

  • Milestone changed from Awaiting Triage to Future Release

comment:8 follow-up: norbertm3 years ago

  • Cc norbert@… added

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

comment:9 in reply to: ↑ 8 norbertm3 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.

comment:10 nacin3 months ago

  • Keywords wptexturize added

comment:11 nacin3 months ago

  • Keywords wpautop added
Note: See TracTickets for help on using tickets.