mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUG Fixing "+" characters being replaced with whitespace
SS_HTMLValue::getContent() uses urldecode() on the content returned by saveHTML() -- this was done to fix encoded HTML entities like square brackets, which are used by shortcodes. Unfortunately, this also removes valid characters like "+" from the content. This fixes it so square bracket entities are decoded *only*, and leaves everything else as-is.
This commit is contained in:
parent
29c2fec977
commit
ac489509be
@ -48,6 +48,10 @@ class SS_HTMLValue extends ViewableData {
|
||||
// strip any surrounding tags before the <body> and after the </body> which are automatically added by
|
||||
// DOMDocument. Note that we can't use the argument to saveHTML() as it's only supported in PHP 5.3.6+,
|
||||
// we support 5.3.2 as a minimum in addition to the above, trim any surrounding newlines from the output
|
||||
|
||||
// shortcodes use square brackets which get escaped into HTML entities by saveHTML()
|
||||
// this manually replaces them back to square brackets so that the shortcodes still work correctly
|
||||
// we can't use urldecode() here, as valid characters like "+" will be incorrectly replaced with spaces
|
||||
return trim(
|
||||
preg_replace(
|
||||
array(
|
||||
@ -55,7 +59,7 @@ class SS_HTMLValue extends ViewableData {
|
||||
'/<\/body>(.*)/is',
|
||||
),
|
||||
'',
|
||||
urldecode($this->getDocument()->saveHTML())
|
||||
str_replace(array('%5B', '%5D'), array('[', ']'), $this->getDocument()->saveHTML())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user