-
-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
* introduce wrapper class to keep unescaped variants available for templates * escape more settings before usage
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
This comment has been minimized.
Sorry, something went wrong. |
||
/** | ||
* | ||
This comment has been minimized.
Sorry, something went wrong. |
||
*/ | ||
class Mage_Core_Model_Security_HtmlEscapedString implements Stringable | ||
{ | ||
|
||
This comment has been minimized.
Sorry, something went wrong. |
||
protected $originalValue; | ||
protected $allowedTags; | ||
|
||
/** | ||
* @param string $originalValue | ||
* @param string[]|null $allowedTags | ||
*/ | ||
public function __construct(string $originalValue, ?array $allowedTags = null) | ||
{ | ||
$this->originalValue = $originalValue; | ||
$this->allowedTags = $allowedTags; | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return (string) Mage::helper('core')->escapeHtml( | ||
$this->originalValue, | ||
$this->allowedTags | ||
); | ||
} | ||
|
||
public function getUnescapedValue(): string | ||
{ | ||
return $this->originalValue; | ||
} | ||
} |
9 comments
on commit 484cf8a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not allowing Mage::getModel here? Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another xss in the backend.. That selfxss is for sure dangerous.. oô
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not $this->escapeHtml()
at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would also be possibe to add a flag to Mage::getStoreConfig($path, $storeId = null, $secureFlag = null)
to escape that values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not allowing Mage::getModel here? Why?
no need for this modularity here. Just because we can do it, doesnt mean we have to.
Why not
$this->escapeHtml()
at all?
to expose a way to still get the unescaped values in templates, for Stores which might actually rely on some of the special characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to expose a way to still get the unescaped values in templates, for Stores which might actually rely on some of the special characters.
Mhh, store the config-value in a variable an escape it - or not - as you need. (to not call it twice)
The unescape value isnt used - it least not in core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not allowing Mage::getModel here? Why?
no need for this modularity here. Just because we can do it, doesnt mean we have to.
But now I have to rewrite the full block instead. Not sure if thats worth. I remember another PR where a new Mage_XXX_Model_XXX
was changed explicity to Mage::getModel
- just to allowe rewrites.
But if its not worth of having, I'm fine with it. It just itched me :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In which situation you would want to rewrite an escaping method?
And with cweagans/composer-patches
its also a lot easier nowdays to patch any core file of any lib.
Anyway, if anyone sees the need to change it, they can provide a PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And with cweagans/composer-patches its also a lot easier nowdays to patch any core file of any lib.
Am i wrong, but composer-patches do not work, when you install OM via git clone???
complete license header is missing