mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-09 23:28:42 +00:00
Fix PHP 4 problems with references.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@211 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
c2ec56b872
commit
77f2833f36
@ -43,15 +43,15 @@ class HTMLPurifier_AttrDef_URI extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
$registry = HTMLPurifier_URISchemeRegistry::instance();
|
$registry =& HTMLPurifier_URISchemeRegistry::instance();
|
||||||
if ($scheme !== null) {
|
if ($scheme !== null) {
|
||||||
// no need to validate the scheme's fmt since we do that when we
|
// no need to validate the scheme's fmt since we do that when we
|
||||||
// retrieve the specific scheme object from the registry
|
// retrieve the specific scheme object from the registry
|
||||||
$scheme = ctype_lower($scheme) ? $scheme : strtolower($scheme);
|
$scheme = ctype_lower($scheme) ? $scheme : strtolower($scheme);
|
||||||
$scheme_obj = $registry->getScheme($scheme);
|
$scheme_obj =& $registry->getScheme($scheme);
|
||||||
if (!$scheme_obj) return ''; // invalid scheme, clean it out
|
if (!$scheme_obj) return ''; // invalid scheme, clean it out
|
||||||
} else {
|
} else {
|
||||||
$scheme_obj = $registry->getScheme($config->get('URI', 'DefaultScheme'));
|
$scheme_obj =& $registry->getScheme($config->get('URI', 'DefaultScheme'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ class HTMLPurifier_AttrDef_URITest extends HTMLPurifier_AttrDefHarness
|
|||||||
// test overlarge port (max is 65535, although this isn't official)
|
// test overlarge port (max is 65535, although this isn't official)
|
||||||
$uri[13] = 'http://example.com:65536';
|
$uri[13] = 'http://example.com:65536';
|
||||||
$components[13] = array('example.com', '', null, null);
|
$components[13] = array('example.com', '', null, null);
|
||||||
$uri[13] = 'http://example.com';
|
$expect_uri[13] = 'http://example.com';
|
||||||
|
|
||||||
// some spec abnf tests
|
// some spec abnf tests
|
||||||
|
|
||||||
@ -157,14 +157,14 @@ class HTMLPurifier_AttrDef_URITest extends HTMLPurifier_AttrDefHarness
|
|||||||
// I cannot set a default value to function parameters that are passed
|
// I cannot set a default value to function parameters that are passed
|
||||||
// by reference. So we use the value instance() returns.
|
// by reference. So we use the value instance() returns.
|
||||||
$fake_registry = new HTMLPurifier_URISchemeRegistryMock($this);
|
$fake_registry = new HTMLPurifier_URISchemeRegistryMock($this);
|
||||||
$registry = HTMLPurifier_URISchemeRegistry::instance($fake_registry);
|
$registry =& HTMLPurifier_URISchemeRegistry::instance($fake_registry);
|
||||||
|
|
||||||
// now, let's at a pseudo-scheme to the registry
|
// now, let's at a pseudo-scheme to the registry
|
||||||
$scheme = new HTMLPurifier_URISchemeMock($this);
|
$scheme =& new HTMLPurifier_URISchemeMock($this);
|
||||||
|
|
||||||
// here are the schemes we will support with overloaded mocks
|
// here are the schemes we will support with overloaded mocks
|
||||||
$registry->setReturnValue('getScheme', $scheme, array('http'));
|
$registry->setReturnReference('getScheme', $scheme, array('http'));
|
||||||
$registry->setReturnValue('getScheme', $scheme, array('mailto'));
|
$registry->setReturnReference('getScheme', $scheme, array('mailto'));
|
||||||
|
|
||||||
// default return value is false (meaning no scheme defined: reject)
|
// default return value is false (meaning no scheme defined: reject)
|
||||||
$registry->setReturnValue('getScheme', false, array('*'));
|
$registry->setReturnValue('getScheme', false, array('*'));
|
||||||
@ -184,7 +184,7 @@ class HTMLPurifier_AttrDef_URITest extends HTMLPurifier_AttrDefHarness
|
|||||||
}
|
}
|
||||||
$result = $def->validate($value);
|
$result = $def->validate($value);
|
||||||
$scheme->tally();
|
$scheme->tally();
|
||||||
$this->assertIdentical($expect_uri[$i], $result);
|
$this->assertIdentical($expect_uri[$i], $result, "Test $i: %s");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user