Skip to content

Commit

Permalink
Correctly handle any $ns used within a text file
Browse files Browse the repository at this point in the history
  • Loading branch information
kolber committed Apr 6, 2011
1 parent fa50aaa commit 50d9715
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/page-data.inc.php
Expand Up @@ -194,6 +194,9 @@ static function create_textfile_vars($page) {

# include shared variables for each page
$shared = (file_exists('./content/_shared.txt')) ? file_get_contents('./content/_shared.txt') : '';
# strip any $n matches from the text, as this will mess with any preg_replaces
# they get put back in after the template has finished being parsed
$text = preg_replace('/\$(\d+)/', "\x02$1", $text);

# remove UTF-8 BOM and marker character in input, if present
$merged_text = preg_replace('/^\xEF\xBB\xBF|\x1A/', '', array($shared, $text));
Expand Down
2 changes: 2 additions & 0 deletions app/parsers/template-parser.inc.php
Expand Up @@ -88,6 +88,8 @@ static function parse($data, $template) {

# we've finished parsing, so return any remaining @ symbols
$template = str_replace("\x01", '@', $template);
# put back any $ characters
$template = str_replace("\x02", '$', $template);

return $template;
}
Expand Down

0 comments on commit 50d9715

Please sign in to comment.