Skip to content

Commit

Permalink
Handle CRLF and BOM carefuly.
Browse files Browse the repository at this point in the history
  • Loading branch information
neochief authored Feb 8, 2019
1 parent 3454953 commit 98b8f28
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Builders/Renderers/IncludeRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@ public function renderContent($content, Page $page, PageRegistry $registry)
}
}
else {
$contents = rtrim($files->get($full_path), "\n");
$contents = $files->get($full_path);
// Remove BOM, if any.
$contents = preg_replace('/^\x{FEFF}/u', '', $contents);
// Normalize line-endings.
$contents = preg_replace("%(\r\n|\r|\n)%", "\n", $contents);
$contents = rtrim($contents, "\n");
}

return $contents;
}, $content);

return $content;
}
}
}

0 comments on commit 98b8f28

Please sign in to comment.