Opened 6 months ago

Last modified 5 weeks ago

#22692 new defect (bug)

Quotes Are Messing Up

Reported by: miqrogroove Owned by:
Priority: normal Milestone: 3.6
Component: Formatting Version: 3.4.2
Severity: normal Keywords: has-patch needs-unit-tests
Cc: jond3r@…

Description

Paste this into the body of a new post:

A sentence.  "A quote after 2 spaces."

Preview that, and be amazed. The first quote is backwards. :(

Due to font differences, this is easiest to see on the Twenty Ten theme.

Attachments (1)

miqro-22692.patch (787 bytes) - added by miqrogroove 7 weeks ago.

Download all attachments as: .zip

Change History (26)

  • Cc jond3r@… added

Isn't this caused by the wptexturize filter?
Try to put

remove_filter('the_content', 'wptexturize');

in the theme's functions.php file.

Isn't this caused by the wptexturize filter?

Yes, It's a bug in the texturize filter, this ticket is to fix it.

Related: #16957 ?

  • Component changed from General to Formatting

comment:5 follow-up: ↓ 6   nacin6 months ago

Cannot reproduce in the editor.

wptexturize( 'A sentence. "A quote after 2 spaces."' ) returns proper quotes.

comment:6 in reply to: ↑ 5   miqrogroove6 months ago

Replying to nacin:

Cannot reproduce in the editor.

Sometimes pasting doesn't preserve both spaces. Try removing the space and hitting spacebar twice from Visual editor. That'll do it.

comment:7 follow-up: ↓ 8   miqrogroove5 months ago

Here's another bug:

"<code>blah</code>"

The trailing quote is backwards when output. 3.4.2 and 3.5 both affected.

comment:8 in reply to: ↑ 7   SergeyBiryukov2 months ago

Replying to miqrogroove:

"<code>blah</code>"

The trailing quote is backwards when output.

Related: #18549

Any chance of getting a milestone for the 2-spaces bug? I'm in the habit of typing with 2 spaces so this bothers me a bit.

Could not reproduce either:

  1. Pasted the example into editor (tried both Text and Visual).
  2. Made sure there are two spaces before the quote.
  3. The post contains proper quotes:
    A sentence.  &#8220;A quote after 2 spaces.&#8221;
    

Tested 3.5.1:

<p>A sentence.  &#8221;A quote after 2 spaces.&#8221;</p>

Please always test trunk.

  • Keywords reporter-feedback added

I can reproduce in 3.5.1 with WP Editor plugin activated, but not on a clean install. Could you try on a clean install?

comment:14 in reply to: ↑ 10   miqrogroove2 months ago

Replying to SergeyBiryukov:

Could not reproduce either:

  1. Pasted the example into editor (tried both Text and Visual).

OK couple things to clarify here. I can't reproduce this bug by pasting or by using the Text tab. Go to the Visual tab, type in the spaces, and then see what happens in preview.

comment:15 follow-up: ↓ 16   miqrogroove7 weeks ago

  • Keywords needs-patch added; reporter-feedback removed

I've also confirmed this is reproducible in 3.6-beta1. Any chance this can get on a milestone now?

comment:16 in reply to: ↑ 15   nacin7 weeks ago

  • Keywords needs-unit-tests added

Replying to miqrogroove:

I've also confirmed this is reproducible in 3.6-beta1. Any chance this can get on a milestone now?

Would need a patch and unit tests for that.

OK, I'm in an optimistic mood today :) The problem is likely in a filter somewhere and I'll track it down.

*sigh*

Not a filter issue. I'm getting different results with identical inputs on two servers now. Starting to suspect an mb string issue. I'll boil this down to a test case for you to look at.

$text = "A sentence. \xC2\xA0\"A quote after 2 spaces.\"";

$opening_quote = '&#8220;';
$closing_quote = '&#8221;';

$dynamic = array();
$dynamic[ '/(\s|\A|[([{<])"(?!\s)/'    ] = '$1' . $opening_quote . '$2'; 
$dynamic[ '/"(\s|\S|\Z)/'              ] = $closing_quote . '$1'; 

$dynamic_characters = array_keys( $dynamic );
$dynamic_replacements = array_values( $dynamic );

echo preg_replace($dynamic_characters, $dynamic_replacements, $text);

The above test case produces bad output on my BlueHost account, but works perfectly on my home server. Configurations are quite different; unsure the culprit. Suspect mb string.

Oops. Fixed it. The PCRE_UTF8 modifier forces identical output on both servers.

$dynamic[ '/(\s|\A|[([{<])"(?!\s)/u'   ] = '$1' . $opening_quote . '$2'; 
$dynamic[ '/"(\s|\S|\Z)/u'             ] = $closing_quote . '$1'; 

I would think that's safe to do as long as everyone is using UTF-8.

  • Keywords needs-patch removed

Patch added.

Btw, I don't do unit testing. What can we do to get this on a milestone now?

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 3.6

Thank you Sergey

Anyone have a few minutes to test my patch?

Note: See TracTickets for help on using tickets.