Make WordPress Core

Opened 13 years ago

Closed 12 years ago

#19854 closed defect (bug) (fixed)

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

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

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 13 years ago.
Make sure we have preg-compatible EOLs
19854.2.diff (543 bytes) - added by solarissmoke 13 years ago.
The lookahead in the first patch was faulty
19854.3.diff (551 bytes) - added by solarissmoke 13 years ago.
nacin's fix

Download all attachments as: .zip

Change History (10)

#1 @solarissmoke
13 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
13 years ago

Make sure we have preg-compatible EOLs

#2 @SergeyBiryukov
13 years ago

  • Milestone changed from Awaiting Review to 3.4

@solarissmoke
13 years ago

The lookahead in the first patch was faulty

#3 @nacin
13 years ago

This probably also works:

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

#4 @solarissmoke
13 years ago

Indeed, that is much more efficient. Patch updated.

@solarissmoke
13 years ago

nacin's fix

#5 @solarissmoke
13 years ago

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

Closed #20248 as duplicate

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

#6 @nacin
12 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
12 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to 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.