Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit conversion to string in htmlspecialchars #387

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Mustache/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ private function prepare($text, $bonus = 0, $prependNewline = true, $appendNewli
return preg_replace("/\n( {8})?/", "\n" . str_repeat(' ', $bonus * 4), $text);
}

const DEFAULT_ESCAPE = 'htmlspecialchars(%s, %s, %s)';
const DEFAULT_ESCAPE = 'htmlspecialchars(%s ?? (string) %s, %s, %s)';
const CUSTOM_ESCAPE = 'call_user_func($this->mustache->getEscape(), %s)';

/**
Expand All @@ -620,7 +620,7 @@ private function getEscape($value = '$value')
return sprintf(self::CUSTOM_ESCAPE, $value);
}

return sprintf(self::DEFAULT_ESCAPE, $value, var_export($this->entityFlags, true), var_export($this->charset, true));
return sprintf(self::DEFAULT_ESCAPE, $value, $value, var_export($this->entityFlags, true), var_export($this->charset, true));
}

/**
Expand Down