WordPress.org

Make WordPress Core

Opened 20 months ago

Last modified 2 weeks 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 (4)

#1 @SergeyBiryukov
20 months ago

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

#2 @jeremyfelt
19 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.

#3 @mikeywil
5 months ago

Thanks for raising this ticket. I came across the same issue today, and mentioned it in support. In a reply, @vladytimy helpfully replicated and illustrated the problem more clearly.

#4 @edent
2 weeks ago

This also occurs when using MarkDown in the classic editor:

Read "[Text](https://example.com)".

Renders as

Read “<a href="https://example.com">text</a>“.
Note: See TracTickets for help on using tickets.