Skip to content

Commit

Permalink
Improves content escaping logic via INI settings
Browse files Browse the repository at this point in the history
  • Loading branch information
octoberapp committed Aug 31, 2023
1 parent aa3388b commit 44fe169
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/Halcyon/Processors/SectionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ public static function render($data, $options = [])
$trim($settings);

// Build content
//
$content = [];

// Settings section
if ($settings) {
$content[] = $iniParser->render($settings);
$content[] = self::cleanContentSections($iniParser->render($settings));
}

// Code section
if ($code) {
if ($wrapCodeInPhpTags) {
$code = preg_replace('/^\<\?php/', '', $code);
Expand All @@ -71,9 +72,10 @@ public static function render($data, $options = [])
}
}
// Strip content separator from content as a method of escape
$content[] = implode('', self::splitContentSections($markup));
// Content section
$content[] = self::cleanContentSections($markup);
// Assemble template content
$content = trim(implode(PHP_EOL.self::SECTION_SEPARATOR.PHP_EOL, $content));
return $content;
Expand Down Expand Up @@ -182,6 +184,15 @@ public static function parseOffset($content)
return $result;
}
/**
* cleanContentSections ensures the content does not attempt to escape its section
* by using the separator sequence. The content separator is simply removed.
*/
protected static function cleanContentSections($content)
{
return implode('', self::splitContentSections($content));
}
/**
* splitContentSections splits a block of content in to sections,
* split by the section separator (==).
Expand Down

0 comments on commit 44fe169

Please sign in to comment.