Opened 6 months ago
Last modified 5 weeks ago
#22692 new defect (bug)
Quotes Are Messing Up
| Reported by: |
|
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)
Change History (26)
Isn't this caused by the wptexturize filter?
Yes, It's a bug in the texturize filter, this ticket is to fix it.
comment:4
SergeyBiryukov — 6 months ago
- Component changed from General to Formatting
Cannot reproduce in the editor.
wptexturize( 'A sentence. "A quote after 2 spaces."' ) returns proper quotes.
comment:6
in reply to:
↑ 5
miqrogroove — 6 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
miqrogroove — 5 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
SergeyBiryukov — 2 months ago
Replying to miqrogroove:
"<code>blah</code>"The trailing quote is backwards when output.
Related: #18549
comment:9
miqrogroove — 2 months ago
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.
comment:10
follow-up:
↓ 14
SergeyBiryukov — 2 months ago
Could not reproduce either:
- Pasted the example into editor (tried both Text and Visual).
- Made sure there are two spaces before the quote.
- The post contains proper quotes:
A sentence. “A quote after 2 spaces.”
comment:11
miqrogroove — 2 months ago
Tested 3.5.1:
<p>A sentence. ”A quote after 2 spaces.”</p>
comment:12
helen — 2 months ago
Please always test trunk.
comment:13
SergeyBiryukov — 2 months ago
- 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
miqrogroove — 2 months ago
Replying to SergeyBiryukov:
Could not reproduce either:
- 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
miqrogroove — 7 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
nacin — 7 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.
comment:17
miqrogroove — 7 weeks ago
OK, I'm in an optimistic mood today :) The problem is likely in a filter somewhere and I'll track it down.
comment:18
miqrogroove — 7 weeks ago
*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.
comment:19
miqrogroove — 7 weeks ago
$text = "A sentence. \xC2\xA0\"A quote after 2 spaces.\"";
$opening_quote = '“';
$closing_quote = '”';
$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.
comment:20
miqrogroove — 7 weeks ago
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.
miqrogroove — 7 weeks ago
comment:22
miqrogroove — 7 weeks ago
Btw, I don't do unit testing. What can we do to get this on a milestone now?
comment:23
SergeyBiryukov — 7 weeks ago
- Keywords has-patch added
- Milestone changed from Awaiting Review to 3.6
comment:24
miqrogroove — 7 weeks ago
Thank you Sergey
comment:25
miqrogroove — 5 weeks ago
Anyone have a few minutes to test my patch?

Isn't this caused by the wptexturize filter?
Try to put
remove_filter('the_content', 'wptexturize');in the theme's functions.php file.