WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 6 years ago

Last modified 6 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 6 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 @chrisbliss187 years ago

  • Status changed from new to assigned

comment:2 @chrisbliss187 years ago

  • Keywords has-patch added

comment:3 @DD327 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?)

comment:4 @FFEMTcJ7 years ago

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

Dup of #8548

comment:5 @automattor7 years ago

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

comment:6 @jacobsantos6 years ago

  • Milestone changed from Unassigned to 2.8

comment:7 @filosofo6 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.

comment:8 @azaozz6 years ago

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

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

comment:9 follow-up: @chrisbliss186 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.

comment:10 in reply to: ↑ 9 @filosofo6 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.