Skip to content

Commit 3f19049

Browse files
committed
Escape minus char in regular expressions
1 parent fa1052a commit 3f19049

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Src/Sunra/PhpSimple/simplehtmldom_1_5/simple_html_dom.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,8 @@ protected function parse_selector($selector_string) {
692692
// Notice the \[ starting the attbute? and the @? following? This implies that an attribute can begin with an @ sign that is not captured.
693693
// This implies that an html attribute specifier may start with an @ sign that is NOT captured by the expression.
694694
// farther study is required to determine of this should be documented or removed.
695-
// $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
696-
$pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
695+
// $pattern = "/([\w\-:\*]*)(?:\#([\w\-]+)|\.([\w\-]+))?(?:\[@?(!?[\w\-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
696+
$pattern = "/([\w\-:\*]*)(?:\#([\w\-]+)|\.([\w\-]+))?(?:\[@?(!?[\w\-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
697697
preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER);
698698
if (is_object($debugObject)) {$debugObject->debugLog(2, "Matches Array: ", $matches);}
699699

@@ -899,7 +899,7 @@ function get_display_size()
899899
{
900900
// Thanks to user gnarf from stackoverflow for this regular expression.
901901
$attributes = array();
902-
preg_match_all("/([\w-]+)\s*:\s*([^;]+)\s*;?/", $this->attr['style'], $matches, PREG_SET_ORDER);
902+
preg_match_all("/([\w\-]+)\s*:\s*([^;]+)\s*;?/", $this->attr['style'], $matches, PREG_SET_ORDER);
903903
foreach ($matches as $match) {
904904
$attributes[$match[1]] = $match[2];
905905
}
@@ -1375,7 +1375,7 @@ protected function read_tag()
13751375
return true;
13761376
}
13771377

1378-
if (!preg_match("/^[\w-:]+$/", $tag)) {
1378+
if (!preg_match("/^[\w\-:]+$/", $tag)) {
13791379
$node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until('<>');
13801380
if ($this->char==='<') {
13811381
$this->link_nodes($node, false);

0 commit comments

Comments
 (0)