mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-05-28 07:19:09 -04:00
Adding SafeString::for_html_attr()
This commit is contained in:
@@ -89,6 +89,25 @@ class SafeString_Core {
|
||||
return self::_escape_for_js($this->_raw_string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe for use in HTML element attributes.
|
||||
*
|
||||
* Assumes that the HTML element attribute is already
|
||||
* delimited by single or double quotes
|
||||
*
|
||||
* Example:<pre>
|
||||
* <a title="<?= $php_var->for_html_attr() ?>">;
|
||||
* </script>
|
||||
* </pre>
|
||||
* @return the string escaped for use in HTML attributes.
|
||||
*/
|
||||
function for_html_attr() {
|
||||
$string = (string) $this->for_html();
|
||||
return strtr($string,
|
||||
array("'"=>"'",
|
||||
'"'=>'"'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe for use HTML (purified HTML)
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user