mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-01 08:54:26 +02:00
Merge branch 'm-haritonov-escape'
This commit is contained in:
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Changed
|
### Changed
|
||||||
- modifier escape now triggers a E_USER_NOTICE when an unsupported escape type is used https://github.com/smarty-php/smarty/pull/649
|
- modifier escape now triggers a E_USER_NOTICE when an unsupported escape type is used https://github.com/smarty-php/smarty/pull/649
|
||||||
|
|
||||||
|
### Security
|
||||||
|
- More advanced javascript escaping to handle https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements thanks to m-haritonov
|
||||||
|
|
||||||
## [3.1.39] - 2021-02-17
|
## [3.1.39] - 2021-02-17
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
@@ -184,7 +184,11 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
|||||||
'"' => '\\"',
|
'"' => '\\"',
|
||||||
"\r" => '\\r',
|
"\r" => '\\r',
|
||||||
"\n" => '\\n',
|
"\n" => '\\n',
|
||||||
'</' => '<\/'
|
'</' => '<\/',
|
||||||
|
// see https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements
|
||||||
|
'<!--' => '<\!--',
|
||||||
|
'<s' => '<\s',
|
||||||
|
'<S' => '<\S'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
case 'mail':
|
case 'mail':
|
||||||
|
@@ -89,9 +89,10 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
|
|||||||
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'",' . $params[ 0 ] . ')';
|
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'",' . $params[ 0 ] . ')';
|
||||||
case 'javascript':
|
case 'javascript':
|
||||||
// escape quotes and backslashes, newlines, etc.
|
// escape quotes and backslashes, newlines, etc.
|
||||||
|
// see https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements
|
||||||
return 'strtr(' .
|
return 'strtr(' .
|
||||||
$params[ 0 ] .
|
$params[ 0 ] .
|
||||||
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
|
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/", "<!--" => "<\!--", "<s" => "<\s", "<S" => "<\S" ))';
|
||||||
}
|
}
|
||||||
} catch (SmartyException $e) {
|
} catch (SmartyException $e) {
|
||||||
// pass through to regular plugin fallback
|
// pass through to regular plugin fallback
|
||||||
|
Reference in New Issue
Block a user