diff options
Diffstat (limited to 'plugins/openid/lib/Auth/Yadis/ParseHTML.php')
-rw-r--r-- | plugins/openid/lib/Auth/Yadis/ParseHTML.php | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/plugins/openid/lib/Auth/Yadis/ParseHTML.php b/plugins/openid/lib/Auth/Yadis/ParseHTML.php index 8b8b33f2..2085cd2c 100644 --- a/plugins/openid/lib/Auth/Yadis/ParseHTML.php +++ b/plugins/openid/lib/Auth/Yadis/ParseHTML.php @@ -52,12 +52,12 @@ class Auth_Yadis_ParseHTML { $this->_removed_re, $this->_re_flags); - $this->_entity_replacements = array( - 'amp' => '&', - 'lt' => '<', - 'gt' => '>', - 'quot' => '"' - ); + $this->_entity_replacements = [ + 'amp' => '&', + 'lt' => '<', + 'gt' => '>', + 'quot' => '"', + ]; $this->_ent_replace = sprintf("&(%s);", implode("|", @@ -75,7 +75,7 @@ class Auth_Yadis_ParseHTML { */ function removeQuotes($str) { - $matches = array(); + $matches = []; $double = '/^"(.*)"$/'; $single = "/^'(.*)'$/"; @@ -136,16 +136,19 @@ class Auth_Yadis_ParseHTML { "", $html_string); - $key_tags = array($this->tagPattern('html', false, false), + $key_tags = [ + $this->tagPattern('html', false, false), $this->tagPattern('head', false, false), $this->tagPattern('head', true, false), $this->tagPattern('html', true, false), - $this->tagPattern(array( + $this->tagPattern([ 'body', 'frameset', 'frame', 'p', 'div', - 'table','span','a'), 'maybe', 'maybe')); - $key_tags_pos = array(); + 'table','span','a' + ], 'maybe', 'maybe') + ]; + $key_tags_pos = []; foreach ($key_tags as $pat) { - $matches = array(); + $matches = []; preg_match($pat, $html_string, $matches, PREG_OFFSET_CAPTURE); if($matches) { $key_tags_pos[] = $matches[0][1]; @@ -155,41 +158,41 @@ class Auth_Yadis_ParseHTML { } // no opening head tag if (is_null($key_tags_pos[1])) { - return array(); + return []; } // the effective </head> is the min of the following if (is_null($key_tags_pos[2])) { $key_tags_pos[2] = strlen($html_string); } - foreach (array($key_tags_pos[3], $key_tags_pos[4]) as $pos) { + foreach ([$key_tags_pos[3], $key_tags_pos[4]] as $pos) { if (!is_null($pos) && $pos < $key_tags_pos[2]) { $key_tags_pos[2] = $pos; } } // closing head tag comes before opening head tag if ($key_tags_pos[1] > $key_tags_pos[2]) { - return array(); + return []; } // if there is an opening html tag, make sure the opening head tag // comes after it if (!is_null($key_tags_pos[0]) && $key_tags_pos[1] < $key_tags_pos[0]) { - return array(); + return []; } $html_string = substr($html_string, $key_tags_pos[1], ($key_tags_pos[2]-$key_tags_pos[1])); - $link_data = array(); - $link_matches = array(); + $link_data = []; + $link_matches = []; if (!preg_match_all($this->tagPattern('meta', false, 'maybe'), $html_string, $link_matches)) { - return array(); + return []; } foreach ($link_matches[0] as $link) { - $attr_matches = array(); + $attr_matches = []; preg_match_all($this->_attr_find, $link, $attr_matches); - $link_attrs = array(); + $link_attrs = []; foreach ($attr_matches[0] as $index => $full_match) { $name = $attr_matches[1][$index]; $value = html_entity_decode( @@ -221,7 +224,7 @@ class Auth_Yadis_ParseHTML { foreach ($meta_tags as $tag) { if (array_key_exists('http-equiv', $tag) && (in_array(strtolower($tag['http-equiv']), - array('x-xrds-location', 'x-yadis-location'))) && + ['x-xrds-location', 'x-yadis-location'])) && array_key_exists('content', $tag)) { return $tag['content']; } |