Make WordPress Core

Opened 12 years ago

Closed 10 years ago

#19308 closed enhancement (fixed)

C-style hexadecimal is incorrectly "fixed" to change the 'x' into a mathematical '×'

Reported by: harrym's profile harrym Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.0 Priority: normal
Severity: normal Version: 2.1
Component: Formatting Keywords: has-patch wptexturize
Focuses: Cc:

Description

Pretty much what the title says. I'm running trunk. "0x07" gets converted to "0×07".

I've attached a patch which fixes this issue by not performing the conversion if the first number starts with a zero -- this is not perfect, and I might have a go at something better when it's not 0030, if you guys decide this should be changed.

My $0.02 - since it's a bit odd to multiply zero by something, I don't think that very many people will expect/want this conversion to happen -- and the lack of conversion is unlikely to confuse those that do.

On the other hand, this conversion is confusing for any blog post using this hex notation, and does make those posts actually wrong.

Attachments (5)

dont-break-hex.diff (1.2 KB) - added by harrym 12 years ago.
19308.patch (1.3 KB) - added by kurtpayne 12 years ago.
Allowing for decimals, commas, negative signs
19308_unit_test.patch (1.3 KB) - added by kurtpayne 12 years ago.
Unit test wptexturize('AxB') for comma, decimal, and hex numbers
miqro-19308.patch (1.4 KB) - added by miqrogroove 10 years ago.
miqro-19308.2.patch (1.4 KB) - added by miqrogroove 10 years ago.
Allow a hyphen in preg_match as well.

Download all attachments as: .zip

Change History (14)

#1 @nacin
12 years ago

At a glance, patch looks great! We'll want unit tests for this.

#2 @SergeyBiryukov
12 years ago

  • Keywords needs-unit-tests added

@kurtpayne
12 years ago

Allowing for decimals, commas, negative signs

@kurtpayne
12 years ago

Unit test wptexturize('AxB') for comma, decimal, and hex numbers

#3 @kurtpayne
12 years ago

  • Cc kpayne@… added

#4 @kurtpayne
12 years ago

  • Type changed from defect (bug) to enhancement
  • Version set to 2.1

#5 @harrym
11 years ago

Now that this has tests, could it be included in 3.7?

#6 @helen
11 years ago

  • Keywords needs-refresh added; needs-unit-tests removed
  • Milestone changed from Awaiting Review to Future Release

Too late for 3.7. Maybe 3.8 - patch needs a refresh to account for new develop repo and probably @ticket annotation for the tests.

#7 @miqrogroove
10 years ago

  • Keywords wptexturize added; needs-refresh removed

In miqro-19308.patch:

  • Unit tests from kurtpayne.
  • A new regexp that uses conditions instead of alternation.
  • It looks for a word break, a single digit, and then tests if that digit is zero.
  • This prevents the engine from testing multiple alternates after every word break.
  • Decimals and commas are allowed after the first digit.
  • Hyphen (negative) also allowed as the first char after the x.

@miqrogroove
10 years ago

Allow a hyphen in preg_match as well.

#8 @wonderboymusic
10 years ago

  • Milestone changed from Future Release to 4.0

#9 @wonderboymusic
10 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 28719:

In wptexturize(), don't convert C-style hexadecimals to mathematical ×.

Adds unit tests.

Props harrym, kurtpayne, miqrogroove.
Fixes #19308.

Note: See TracTickets for help on using tickets.