WordPress.org

Make WordPress Core

Opened 10 years ago

Closed 6 years ago

Last modified 16 months ago

#1418 closed defect (bug) (fixed)

wptexturize doesn't correctly translate doublequote in brackets

Reported by: Kafkaesqui Owned by:
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.8.4
Component: Formatting Keywords: dev-feedback has-patch needs-testing
Focuses: Cc:

Description

When a doublequote directly follows an opening bracket (parenthesis, etc), the quote is incorrectly translated to the closing doublequote ncr (”). I've modified line 30 of functions-formatting.php to partially account for non-whitespace characters before the opening quote.

Attachments (2)

wptexturize.patch (772 bytes) - added by Kafkaesqui 10 years ago.
Patch to functions-formatting.php for wptexturize doublequote regexp fix.
quotes_in_parentheses.patch (1.1 KB) - added by voyou1 6 years ago.

Download all attachments as: .zip

Change History (18)

@Kafkaesqui10 years ago

Patch to functions-formatting.php for wptexturize doublequote regexp fix.

comment:1 @kafkaesqui10 years ago

  • Keywords bg|has-patch bg|dev-feedback added

comment:2 @matt10 years ago

  • Milestone changed from 1.6 to 2.1

comment:3 @matt9 years ago

  • Milestone changed from 2.1 to 2.2

comment:4 @foolswisdom8 years ago

  • Keywords has-patch dev-feedback added; bg|has-patch bg|dev-feedback removed
  • Milestone changed from 2.2 to 2.3

comment:5 @rob1n8 years ago

  • Keywords has-patch formatting wptexturize curl quotes removed

Patch won't apply -- for one thing the filenames are different now.

Also, I'm not fluent in REGEX, so I'm not sure. Probably needs testing.

comment:6 @rob1n8 years ago

  • Component changed from Administration to General

comment:7 @markjaquith8 years ago

  • Milestone changed from 2.3 to 2.4 (next)

We need some examples of input text and output text (and desired output).

comment:8 @jokeofalltrades8 years ago

Example:
("ABC") should render as (“NRDC”), but in fact renders as (”ABC“) - precisely backwards. These types of expressions are often used in legal texts (and lots of other texts) to signify abbreviations that will be used throughout the text the first time they are encountered. The only example I can find at the moment is here (search for "NRDC").

As far as I can see, ideal behavior for wptexturize would require that:
(1) opening quotes (entities &#8220 or &#8216) never appear immediately before a closing bracket of any sort or whitespace of any sort; and
(2) closing double quotes (entity &#8221) should never appear immediately after an opening bracket of any sort or whitespace of any sort.

The closing single quote (entity &#8217) is trickier, because there may be times when a parenthetical or other bracketed expression starts with a contracted year reference or a slang term ("cockney") beginning with an apostrophe (though these should be rare), and obviously any of those expressions will usually be preceded by whitespace.

The two rules above, though, should be top-level rules that trump all other smart-quote replacement rules, shouldn't they?

See also ticket #1258 for problems with quotes near whitespace.

comment:9 @jokeofalltrades8 years ago

Oops, that should read:
Example: ("ABC") should render as (“ABC”), but in fact renders as (”ABC“) - precisely backwards.

comment:10 @thee177 years ago

  • Keywords recomend-closing added

comment:11 @Nazgul7 years ago

  • Milestone 2.5 deleted
  • Resolution set to wontfix
  • Status changed from new to closed

I agree with thee17, so closing as wontfix for now.

Feel free to re-open if you have additional patches/information/suggestions/...

comment:12 @voyou16 years ago

  • Cc voyou1 added
  • Component changed from General to Formatting
  • Keywords recomend-closing removed
  • Resolution wontfix deleted
  • Status changed from closed to reopened
  • Version changed from 1.5.1.1 to 2.8.4

I'm reopening, as this bug still exists. The current behaviour is:

  • ("test") converts to (”test”)
    • incorrect, should be (“test”)
  • ('test') converts to (’test’)
    • incorrect, should be (‘test’)
  • ('twas) converts to (’twas)
    • correct, cockney.

I've attached a patch against HEAD which fixes the two incorrect behaviours, and doesn't alter the third, correct, behaviour.

comment:13 @westi6 years ago

  • Milestone set to 2.9

comment:14 @voyou16 years ago

  • Keywords has-patch needs-testing added

comment:15 @westi6 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

Fixed in [11813]

comment:16 @SergeyBiryukov16 months ago

#9306 was marked as a duplicate.

Note: See TracTickets for help on using tickets.