WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#9244 closed defect (bug) (fixed)

Hyphen in Theme Directory Breaks Theme Preview

Reported by: chrisjean Owned by: chrisbliss18
Milestone: 2.8 Priority: normal
Severity: trivial Version: 2.8
Component: Themes Keywords: theme, preview, has-patch
Focuses: Cc:

Description

There is a bug in the regex expressions in the preview_theme() function. The hyphen is not escaped, so themes that have hyphens in the directory name cause the function to return rather than continue. Thus, when previewing a theme with a hypen in the directory, all that is rendered is a white page.

The attached diff corrects this issue when scrubbing both the template and the stylesheet.

Attachments (2)

theme-preview-bug.diff (927 bytes) - added by chrisbliss18 7 years ago.
less_confusing.9244.diff (927 bytes) - added by filosofo 7 years ago.

Download all attachments as: .zip

Change History (12)

#1 @chrisbliss18
7 years ago

  • Status changed from new to assigned

#2 @chrisbliss18
7 years ago

  • Keywords has-patch added

#3 @DD32
7 years ago

See: #8548 (reopened defect (bug)): Theme preview fails when theme in subdirectory

(Might be best to close as duplicate and add patch over there?)

#4 @FFEMTcJ
7 years ago

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

Dup of #8548

#5 @automattor
7 years ago

(In [10677]) Escape hyphen in regex. Props chrisbliss18. fixes #8548 #9244 for 2.7

#6 @jacobsantos
7 years ago

  • Milestone changed from Unassigned to 2.8

#7 @filosofo
7 years ago

  • Resolution fixed deleted
  • Severity changed from normal to trivial
  • Status changed from closed to reopened

This is probably overly punctilious, but the backslash is unnecessary and its intended purpose might seem unclear to people in the future. Patch attached.

#8 @azaozz
7 years ago

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

(In [10824]) Less confusing regex, props filosofo, fixes #9244

#9 follow-up: @chrisbliss18
7 years ago

Just to play devil's advocate here, I'm not sure how putting the hyphen at the end again is less confusing. It simply adds the potential of reintroducing this bug if someone adds yet another character at the end of the character class.

#10 in reply to: ↑ 9 @filosofo
7 years ago

Replying to chrisbliss18:

Just to play devil's advocate here, I'm not sure how putting the hyphen at the end again is less confusing. It simply adds the potential of reintroducing this bug if someone adds yet another character at the end of the character class.

A mere backslash won't prevent all the potential damage to a regex done by someone who modifies it without understanding.

Moving the hyphen to the beginning or the end of the character class makes its purpose unambiguous to a knowledgeable person, and it eliminates an excess character.

And now I must return to trimming my lawn with a nail clipper.

Note: See TracTickets for help on using tickets.