Opened 16 months ago
Closed 13 months ago
#19854 closed defect (bug) (fixed)
themes.php doesn't show themes if using Mac-style CR EOL markers
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.4 |
| Component: | Themes | Version: | 3.3.1 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | aren@… |
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)
Change History (10)
comment:1
solarissmoke — 16 months ago
- Keywords has-patch added
comment:2
SergeyBiryukov — 16 months ago
- Milestone changed from Awaiting Review to 3.4
This probably also works:
$file_data = str_replace( array( "\r\n", "\r" ), "\n", $file_data );
comment:4
solarissmoke — 16 months ago
Indeed, that is much more efficient. Patch updated.
comment:5
solarissmoke — 14 months 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
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].

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.