WordPress.org

Make WordPress Core

Opened 12 months ago

Last modified 11 months ago

#48602 new defect (bug)

wptexturize: smart quotes: should ignore tags inside quotes

Reported by: kurakin_alexander Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 5.2.2
Component: Formatting Keywords: has-patch needs-unit-tests
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Source (in editor):

"abc <a href="http://site.com">def</a>".

After save:

Actual: «abc [http://site.com def]«.
Expected: «abc [http://site.com def]».

Change History (2)

#1 @SergeyBiryukov
12 months ago

  • Component changed from General to Formatting
  • Description modified (diff)

#2 @jeremyfelt
11 months ago

  • Keywords has-patch needs-unit-tests added
  • Milestone changed from Awaiting Review to Future Release

Thanks for opening this ticket, @kurakin_alexander, I've run into this myself recently.

A few variations:

# This should be 8220 and 8221
wp> wptexturize( '"<em>these quotes are wrong!</em>"' );
string(46) "&#8220;<em>these quotes are wrong!</em>&#8220;"

# This should be 8220 and 8221. The em dash causes a flip of sorts.
wp> wptexturize( 'Interrupt this with a quote—"<em>these quotes are wrong!</em>"' );
string(76) "Interrupt this with a quote—&#8221;<em>these quotes are wrong!</em>&#8220;"

# And as a bonus, this should be 8220 and 8221, but has no tags, just a preceding em dash.
wp> wptexturize( 'Interrupt this with a quote—"these quotes are wrong!"' );
string(67) "Interrupt this with a quote—&#8221;these quotes are wrong!&#8221;"

A first patch could probably add those to the tests.

Note: See TracTickets for help on using tickets.