Make WordPress Core

Opened 15 years ago

Closed 14 years ago

#19854 closed defect (bug) (fixed)

themes.php doesn't show themes if using Mac-style CR EOL markers

Reported by: novasource Owned by: nacin
Priority: normal Milestone: 3.4
Component: Themes Version: 3.3.1
Severity: normal Keywords: has-patch
Cc: Focuses:

Description

Apparently Macs by default only use CRs to mark end of lines.

If a child theme's style.css file was saved using this, which can happen in Dreamweaver, WordPress won't even show the child theme at wp-admin/themes.php. This has come up at ​http://wordpress.org/support/topic/child-themes-doesnt-show-up-in-mamp.

If EOL only with CR isn't supported, it would be nice to at least show a warning.

Attachments (3)

19854.diff​ (544 bytes ) - added by solarissmoke 15 years ago.
Make sure we have preg-compatible EOLs
19854.2.diff​ (543 bytes ) - added by solarissmoke 15 years ago.
The lookahead in the first patch was faulty
19854.3.diff​ (551 bytes ) - added by solarissmoke 15 years ago.
nacin's fix

Download all attachments as: .zip

Change History (10)

#1 @solarissmoke
15 years ago

  • Keywords has-patch added

This happens with plugins also.

Tracked it down to the regex in get_file_data(). The line start/end metacharacters (^ and $) require a LF (\n) in order to detect the start/end of a line - which of course isn't there if you just have CR (\r). Fix seems relatively simple.

@solarissmoke
15 years ago

Make sure we have preg-compatible EOLs

#2 @SergeyBiryukov
15 years ago

  • Milestone Awaiting Review → 3.4

@solarissmoke
15 years ago

The lookahead in the first patch was faulty

#3 @nacin
15 years ago

This probably also works:

$file_data = str_replace( array( "\r\n", "\r" ), "\n", $file_data );

#4 @solarissmoke
15 years ago

Indeed, that is much more efficient. Patch updated.

@solarissmoke
15 years ago

nacin's fix

#5 @solarissmoke
15 years ago

  • Summary themes.php doesn't show child themes if using Mac-style CR EOL markers → themes.php doesn't show themes if using Mac-style CR EOL markers

Closed #20248 as duplicate

Last edited 15 years ago by helenyhou (previous) (diff)

#6 @nacin
14 years ago

No need to even replace \r\n; we just need to replace \r with \n. If an \r\n becomes \n\n, the function will still end up with the right data.

Added test cases in ​[UT703].

#7 @nacin
14 years ago

  • Owner set to nacin
  • Resolution → fixed
  • Status new → closed

In [20640]:

Properly extract file headers via get_file_data() when CR line endings are used. props solarissmoke for the initial patch. fixes #19854.

Note: See TracTickets for help on using tickets.