Code: Select all
$metaRegex = "%<meta[^>]+http-equiv=([\"]{0,1})([^\"]*)([\"]{0,1})[^>]+content=([\"]{0,1})([^\"]*)([\"]{0,1})[^>]*>%i";Moderator: General Moderators
Code: Select all
$metaRegex = "%<meta[^>]+http-equiv=([\"]{0,1})([^\"]*)([\"]{0,1})[^>]+content=([\"]{0,1})([^\"]*)([\"]{0,1})[^>]*>%i";Code: Select all
/**
* Assuming this user is hosting a third party sourced identity under an
* alias personal URL, we'll need to check if the website's HTML body
* has a http-equiv meta element with a content attribute pointing to where
* we can fetch the XRD document.
*
* @param Zend_Http_Response $response
* @return boolean
* @throws Zend_Service_Yadis_Exception
*/
protected function _isMetaHttpEquiv(Zend_Http_Response $response)
{
if (!in_array($response->getHeader('Content-Type'), $this->_validHtmlContentTypes)) {
return false;
}
/**
* Find a match for a relevant <meta> element, then iterate through the
* results to see if a valid http-equiv value and matching content URI
* exist.
* Todo: need to check this is located inside the <head> element too.
*/
$metaRegex = "%<meta[^>]+http-equiv=([\"]{0,1})([^\"]*)([\"]{0,1})[^>]+content=([\"]{0,1})([^\"]*)([\"]{0,1})[^>]*>%i";
$matches = null;
$location = null;
preg_match_all($metaRegex, $response->getBody(), $matches, PREG_PATTERN_ORDER);
for ($i=0;$i < count($matches[1]);$i++) {
if (strtolower($matches[1][$i]) == "x-xrds-location" || strtolower($matches[1][$i]) == "x-yadis-location") {
$location = $matches[2][$i];
}
}
if (empty($location)) {
return false;
} elseif (!Zend_Uri::check($location)) {
require_once 'Zend/Service/Yadis/Exception.php';
throw new Zend_Service_Yadis_Exception('The URI parsed from the HTML document appears to be invalid: ' . htmlentities($location, ENT_QUOTES, 'utf-8'));
}
/**
* Should now contain the content value of the http-equiv type pointing
* to an XRDS resource for the user's Identity Provider, as found by
* passing the meta regex across the response body.
*/
$this->_metaHttpEquivUrl = $location;
return true;
}Try this:Maugrim_The_Reaper wrote:Code: Select all
$metaRegex = "%<meta[^>]+http-equiv=(["]{0,1})([^"]*)(["]{0,1})[^>]+content=(["]{0,1})([^"]*)(["]{0,1})[^>]*>%i";
Code: Select all
< meta hmm = " ooh?" http-equiv = 'other quotes' hey="not fair!" content='could be before "http-equiv" as well' >