Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Security improvements and version bump
Security improvements.
- Loading branch information
Showing
10 changed files
with
121 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Miniorange\Helper\lib\XMLSecLibs\Utils; | ||
|
||
class XPath | ||
{ | ||
const ALPHANUMERIC = '\w\d'; | ||
const NUMERIC = '\d'; | ||
const LETTERS = '\w'; | ||
const EXTENDED_ALPHANUMERIC = '\w\d\s\-_:\.'; | ||
|
||
const SINGLE_QUOTE = '\''; | ||
const DOUBLE_QUOTE = '"'; | ||
const ALL_QUOTES = '[\'"]'; | ||
|
||
|
||
/** | ||
* Filter an attribute value for save inclusion in an XPath query. | ||
* | ||
* @param string $value The value to filter. | ||
* @param string $quotes The quotes used to delimit the value in the XPath query. | ||
* | ||
* @return string The filtered attribute value. | ||
*/ | ||
public static function filterAttrValue($value, $quotes = self::ALL_QUOTES) | ||
{ | ||
return preg_replace('#'.$quotes.'#', '', $value); | ||
} | ||
|
||
|
||
/** | ||
* Filter an attribute name for save inclusion in an XPath query. | ||
* | ||
* @param string $name The attribute name to filter. | ||
* @param mixed $allow The set of characters to allow. Can be one of the constants provided by this class, or a | ||
* custom regex excluding the '#' character (used as delimiter). | ||
* | ||
* @return string The filtered attribute name. | ||
*/ | ||
public static function filterAttrName($name, $allow = self::EXTENDED_ALPHANUMERIC) | ||
{ | ||
return preg_replace('#[^'.$allow.']#', '', $name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.