Server geändert

This commit is contained in:
aschwarz
2023-04-25 13:12:50 +02:00
parent 5e9c9cf19d
commit 57b74ca3a5
647 changed files with 3051 additions and 3051 deletions

View File

@ -10,18 +10,18 @@ class HTMLPurifier_AttrDef_CSS_URITest extends HTMLPurifier_AttrDefHarness
$this->assertDef('', false);
// we could be nice but we won't be
$this->assertDef('http://www.example.com/', false);
$this->assertDef('https://www.example.com/', false);
$this->assertDef('url(', false);
$this->assertDef('url("")', true);
$result = 'url("http://www.example.com/")';
$this->assertDef('url(http://www.example.com/)', $result);
$this->assertDef('url("http://www.example.com/")', $result);
$this->assertDef("url('http://www.example.com/')", $result);
$result = 'url("https://www.example.com/")';
$this->assertDef('url(https://www.example.com/)', $result);
$this->assertDef('url("https://www.example.com/")', $result);
$this->assertDef("url('https://www.example.com/')", $result);
$this->assertDef(
' url( "http://www.example.com/" ) ', $result);
$this->assertDef("url(http://www.example.com/foo,bar\)\'\()",
'url("http://www.example.com/foo,bar%29%27%28")');
' url( "https://www.example.com/" ) ', $result);
$this->assertDef("url(https://www.example.com/foo,bar\)\'\()",
'url("https://www.example.com/foo,bar%29%27%28")');
}
}

View File

@ -20,7 +20,7 @@ class HTMLPurifier_AttrDef_URI_HostTest extends HTMLPurifier_AttrDefHarness
$this->assertDef('.test', false);
$this->assertDef('ff');
$this->assertDef('1f'); // per RFC 1123
// See also http://serverfault.com/questions/638260/is-it-valid-for-a-hostname-to-start-with-a-digit
// See also https://serverfault.com/questions/638260/is-it-valid-for-a-hostname-to-start-with-a-digit
$this->assertDef('-f', false);
$this->assertDef('f1');
$this->assertDef('f-', false);

View File

@ -14,9 +14,9 @@ class HTMLPurifier_AttrDef_URITest extends HTMLPurifier_AttrDefHarness
public function testIntegration()
{
$this->assertDef('http://www.google.com/');
$this->assertDef('http:', '');
$this->assertDef('http:/foo', '/foo');
$this->assertDef('https://www.google.com/');
$this->assertDef('https:', '');
$this->assertDef('https:/foo', '/foo');
$this->assertDef('javascript:bad_stuff();', false);
$this->assertDef('ftp://www.example.com/');
$this->assertDef('news:rec.alt');
@ -28,15 +28,15 @@ class HTMLPurifier_AttrDef_URITest extends HTMLPurifier_AttrDefHarness
public function testIntegrationWithPercentEncoder()
{
$this->assertDef(
'http://www.example.com/%56%fc%GJ%5%FC',
'http://www.example.com/V%FC%25GJ%255%FC'
'https://www.example.com/%56%fc%GJ%5%FC',
'https://www.example.com/V%FC%25GJ%255%FC'
);
}
public function testPercentEncoding()
{
$this->assertDef(
'http:colon:mercenary',
'https:colon:mercenary',
'colon%3Amercenary'
);
}
@ -44,23 +44,23 @@ class HTMLPurifier_AttrDef_URITest extends HTMLPurifier_AttrDefHarness
public function testPercentEncodingPreserve()
{
$this->assertDef(
'http://www.example.com/abcABC123-_.!~*()\''
'https://www.example.com/abcABC123-_.!~*()\''
);
}
public function testEmbeds()
{
$this->def = new HTMLPurifier_AttrDef_URI(true);
$this->assertDef('http://sub.example.com/alas?foo=asd');
$this->assertDef('https://sub.example.com/alas?foo=asd');
$this->assertDef('mailto:foo@example.com', false);
}
public function testConfigMunge()
{
$this->config->set('URI.Munge', 'http://www.google.com/url?q=%s');
$this->config->set('URI.Munge', 'https://www.google.com/url?q=%s');
$this->assertDef(
'http://www.example.com/',
'http://www.google.com/url?q=http%3A%2F%2Fwww.example.com%2F'
'https://www.example.com/',
'https://www.google.com/url?q=http%3A%2F%2Fwww.example.com%2F'
);
$this->assertDef('index.html');
$this->assertDef('javascript:foobar();', false);
@ -68,17 +68,17 @@ class HTMLPurifier_AttrDef_URITest extends HTMLPurifier_AttrDefHarness
public function testDefaultSchemeRemovedInBlank()
{
$this->assertDef('http:', '');
$this->assertDef('https:', '');
}
public function testDefaultSchemeRemovedInRelativeURI()
{
$this->assertDef('http:/foo/bar', '/foo/bar');
$this->assertDef('https:/foo/bar', '/foo/bar');
}
public function testDefaultSchemeNotRemovedInAbsoluteURI()
{
$this->assertDef('http://example.com/foo/bar');
$this->assertDef('https://example.com/foo/bar');
}
public function testDefaultSchemeNull()
@ -106,7 +106,7 @@ class HTMLPurifier_AttrDef_URITest extends HTMLPurifier_AttrDefHarness
public function testURIDefinitionValidation()
{
$parser = new HTMLPurifier_URIParser();
$uri = $parser->parse('http://example.com');
$uri = $parser->parse('https://example.com');
$this->config->set('URI.DefinitionID', 'HTMLPurifier_AttrDef_URITest->testURIDefinitionValidation');
generate_mock_once('HTMLPurifier_URIDefinition');
@ -132,7 +132,7 @@ class HTMLPurifier_AttrDef_URITest extends HTMLPurifier_AttrDefHarness
HTMLPurifier_DefinitionCacheFactory::instance($factory_mock);
$factory_mock->returns('create', $cache_mock);
$this->assertDef('http://example.com');
$this->assertDef('https://example.com');
HTMLPurifier_DefinitionCacheFactory::instance($old);
}
@ -155,10 +155,10 @@ class HTMLPurifier_AttrDef_URITest extends HTMLPurifier_AttrDefHarness
$this->config->set('URI.HostPolicy', 'DenyAll');
$this->config->set('URI.HostWhitelist', array(null, 'google.com'));
$this->assertDef('http://example.com/fo/google.com', false);
$this->assertDef('https://example.com/fo/google.com', false);
$this->assertDef('server.txt');
$this->assertDef('ftp://www.google.com/?t=a');
$this->assertDef('http://google.com.tricky.spamsite.net', false);
$this->assertDef('https://google.com.tricky.spamsite.net', false);
}
*/

View File

@ -97,7 +97,7 @@ class HTMLPurifier_ErrorCollectorTest extends HTMLPurifier_Harness
$this->context->register('CurrentToken', $current_token);
// 0
$current_token = new HTMLPurifier_Token_Start('a', array('href' => 'http://example.com'), 32);
$current_token = new HTMLPurifier_Token_Start('a', array('href' => 'https://example.com'), 32);
$this->language->returns('formatMessage', 'Token message',
array('message-data-token', array('CurrentToken' => $current_token)));
$this->collector->send(E_NOTICE, 'message-data-token');
@ -116,7 +116,7 @@ class HTMLPurifier_ErrorCollectorTest extends HTMLPurifier_Harness
$result = array(
0 => array(32, E_NOTICE, 'Token message', array()),
1 => array(32, E_NOTICE, '$CurrentAttr.Name => $CurrentAttr.Value', array()),
2 => array(32, E_NOTICE, 'href => http://example.com', array())
2 => array(32, E_NOTICE, 'href => https://example.com', array())
);
$this->assertIdentical($this->collector->getRaw(), $result);

View File

@ -253,7 +253,7 @@ text-align:center
public function test_cleanCSS_caseSensitive()
{
$this->assertCleanCSS("a .foo #ID div.cl#foo {\nbackground:url(\"http://foo/BAR\")\n}");
$this->assertCleanCSS("a .foo #ID div.cl#foo {\nbackground:url(\"https://foo/BAR\")\n}");
}
public function test_extractStyleBlocks_backtracking()

View File

@ -15,7 +15,7 @@ class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
$this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
$this->assertResult( // need support for label for later
'
<form action="http://somesite.com/prog/adduser" method="post">
<form action="https://somesite.com/prog/adduser" method="post">
<p>
<label>First name: </label>
<input type="text" id="firstname" /><br />
@ -35,7 +35,7 @@ class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
{
$this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
$this->assertResult('
<form action="http://somesite.com/prog/component-select" method="post">
<form action="https://somesite.com/prog/component-select" method="post">
<p>
<select multiple="multiple" size="4" name="component-select">
<option selected="selected" value="Component_1_a">Component_1</option>
@ -56,7 +56,7 @@ class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
{
$this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
$this->assertResult('
<form action="http://somesite.com/prog/someprog" method="post">
<form action="https://somesite.com/prog/someprog" method="post">
<p>
<select name="ComOS">
<option selected="selected" label="none" value="none">None</option>
@ -83,7 +83,7 @@ class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
{
$this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
$this->assertResult('
<form action="http://somesite.com/prog/text-read" method="post">
<form action="https://somesite.com/prog/text-read" method="post">
<p>
<textarea name="thetext" rows="20" cols="80">
First line of initial text.

View File

@ -13,15 +13,15 @@ class HTMLPurifier_HTMLModule_NofollowTest extends HTMLPurifier_HTMLModuleHarnes
public function testNofollow()
{
$this->assertResult(
'<a href="http://google.com">x</a><a href="http://google.com" rel="blah">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>',
'<a href="http://google.com" rel="nofollow">x</a><a href="http://google.com" rel="blah nofollow">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>'
'<a href="https://google.com">x</a><a href="https://google.com" rel="blah">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>',
'<a href="https://google.com" rel="nofollow">x</a><a href="https://google.com" rel="blah nofollow">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>'
);
}
public function testNofollowDupe()
{
$this->assertResult(
'<a href="http://google.com" rel="nofollow">x</a><a href="http://google.com" rel="blah nofollow">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>'
'<a href="https://google.com" rel="nofollow">x</a><a href="https://google.com" rel="blah nofollow">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>'
);
}

View File

@ -25,12 +25,12 @@ class HTMLPurifier_HTMLModule_ObjectTest extends HTMLPurifier_HTMLModuleHarness
public function testStandardUseCase()
{
$this->assertResult(
'<object type="video/x-ms-wmv" data="http://domain.com/video.wmv" width="320" height="256">
<param name="src" value="http://domain.com/video.wmv" />
'<object type="video/x-ms-wmv" data="https://domain.com/video.wmv" width="320" height="256">
<param name="src" value="https://domain.com/video.wmv" />
<param name="autostart" value="false" />
<param name="controller" value="true" />
<param name="pluginurl" value="http://www.microsoft.com/Windows/MediaPlayer/" />
<a href="http://www.microsoft.com/Windows/MediaPlayer/">Windows Media player required</a>
<param name="pluginurl" value="https://www.microsoft.com/Windows/MediaPlayer/" />
<a href="https://www.microsoft.com/Windows/MediaPlayer/">Windows Media player required</a>
</object>'
);
}

View File

@ -13,31 +13,31 @@ class HTMLPurifier_HTMLModule_SafeEmbedTest extends HTMLPurifier_HTMLModuleHarne
public function testMinimal()
{
$this->assertResult(
'<embed src="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" />',
'<embed src="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" allowscriptaccess="never" allownetworking="internal" type="application/x-shockwave-flash" />'
'<embed src="https://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" />',
'<embed src="https://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" allowscriptaccess="never" allownetworking="internal" type="application/x-shockwave-flash" />'
);
}
public function testYouTube()
{
$this->assertResult(
'<embed src="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" type="application/x-shockwave-flash" width="425" height="344"></embed>',
'<embed src="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" type="application/x-shockwave-flash" width="425" height="344" allowscriptaccess="never" allownetworking="internal" />'
'<embed src="https://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" type="application/x-shockwave-flash" width="425" height="344"></embed>',
'<embed src="https://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" type="application/x-shockwave-flash" width="425" height="344" allowscriptaccess="never" allownetworking="internal" />'
);
}
public function testMalicious()
{
$this->assertResult(
'<embed src="http://example.com/bad.swf" type="application/x-shockwave-flash" width="9999999" height="3499994" allowscriptaccess="always" allownetworking="always" />',
'<embed src="http://example.com/bad.swf" type="application/x-shockwave-flash" width="1200" height="1200" allowscriptaccess="never" allownetworking="internal" />'
'<embed src="https://example.com/bad.swf" type="application/x-shockwave-flash" width="9999999" height="3499994" allowscriptaccess="always" allownetworking="always" />',
'<embed src="https://example.com/bad.swf" type="application/x-shockwave-flash" width="1200" height="1200" allowscriptaccess="never" allownetworking="internal" />'
);
}
public function testFull()
{
$this->assertResult(
'<b><embed src="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" type="application/x-shockwave-flash" width="24" height="23" allowscriptaccess="never" allownetworking="internal" wmode="window" /></b>'
'<b><embed src="https://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" type="application/x-shockwave-flash" width="24" height="23" allowscriptaccess="never" allownetworking="internal" wmode="window" /></b>'
);
}

View File

@ -22,23 +22,23 @@ class HTMLPurifier_HTMLModule_SafeObjectTest extends HTMLPurifier_HTMLModuleHarn
{
// embed is purposely removed
$this->assertResult(
'<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/RVtEQxH7PWA&hl=en"></param><embed src="http://www.youtube.com/v/RVtEQxH7PWA&hl=en" type="application/x-shockwave-flash" width="425" height="344"></embed></object>',
'<object width="425" height="344" data="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" type="application/x-shockwave-flash"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" /></object>'
'<object width="425" height="344"><param name="movie" value="https://www.youtube.com/v/RVtEQxH7PWA&hl=en"></param><embed src="https://www.youtube.com/v/RVtEQxH7PWA&hl=en" type="application/x-shockwave-flash" width="425" height="344"></embed></object>',
'<object width="425" height="344" data="https://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" type="application/x-shockwave-flash"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="https://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" /></object>'
);
}
public function testMalicious()
{
$this->assertResult(
'<object width="9999999" height="9999999"><param name="allowScriptAccess" value="always" /><param name="movie" value="http://example.com/attack.swf" /></object>',
'<object width="1200" height="1200" data="http://example.com/attack.swf" type="application/x-shockwave-flash"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="http://example.com/attack.swf" /></object>'
'<object width="9999999" height="9999999"><param name="allowScriptAccess" value="always" /><param name="movie" value="https://example.com/attack.swf" /></object>',
'<object width="1200" height="1200" data="https://example.com/attack.swf" type="application/x-shockwave-flash"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="https://example.com/attack.swf" /></object>'
);
}
public function testFull()
{
$this->assertResult(
'<b><object width="425" height="344" type="application/x-shockwave-flash" data="Foobar"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="flashvars" value="foobarbaz=bally" /><param name="movie" value="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" /><param name="wmode" value="window" /></object></b>'
'<b><object width="425" height="344" type="application/x-shockwave-flash" data="Foobar"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="flashvars" value="foobarbaz=bally" /><param name="movie" value="https://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" /><param name="wmode" value="window" /></object></b>'
);
}
@ -46,7 +46,7 @@ class HTMLPurifier_HTMLModule_SafeObjectTest extends HTMLPurifier_HTMLModuleHarn
{
$this->config->set('HTML.FlashAllowFullScreen', true);
$this->assertResult(
'<b><object width="425" height="344" type="application/x-shockwave-flash" data="Foobar"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="flashvars" value="foobarbaz=bally" /><param name="movie" value="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" /><param name="wmode" value="window" /><param name="allowFullScreen" value="true" /></object></b>'
'<b><object width="425" height="344" type="application/x-shockwave-flash" data="Foobar"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="flashvars" value="foobarbaz=bally" /><param name="movie" value="https://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" /><param name="wmode" value="window" /><param name="allowFullScreen" value="true" /></object></b>'
);
}

View File

@ -6,7 +6,7 @@ class HTMLPurifier_HTMLModule_SafeScriptingTest extends HTMLPurifier_HTMLModuleH
public function setUp()
{
parent::setUp();
$this->config->set('HTML.SafeScripting', array('http://localhost/foo.js'));
$this->config->set('HTML.SafeScripting', array('https://localhost/foo.js'));
}
public function testMinimal()
@ -20,14 +20,14 @@ class HTMLPurifier_HTMLModule_SafeScriptingTest extends HTMLPurifier_HTMLModuleH
public function testGood()
{
$this->assertResult(
'<script type="text/javascript" src="http://localhost/foo.js" />'
'<script type="text/javascript" src="https://localhost/foo.js" />'
);
}
public function testBad()
{
$this->assertResult(
'<script type="text/javascript" src="http://localhost/foobar.js" />',
'<script type="text/javascript" src="https://localhost/foobar.js" />',
''
);
}

View File

@ -12,15 +12,15 @@ class HTMLPurifier_HTMLModule_TargetBlankTest extends HTMLPurifier_HTMLModuleHar
public function testTargetBlank()
{
$this->assertResult(
'<a href="http://google.com">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>',
'<a href="http://google.com" target="_blank" rel="noreferrer noopener">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>'
'<a href="https://google.com">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>',
'<a href="https://google.com" target="_blank" rel="noreferrer noopener">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>'
);
}
public function testTargetBlankNoDupe() {
$this->assertResult(
'<a href="http://google.com" target="_blank">a</a>',
'<a href="http://google.com" target="_blank" rel="noreferrer noopener">a</a>'
'<a href="https://google.com" target="_blank">a</a>',
'<a href="https://google.com" target="_blank" rel="noreferrer noopener">a</a>'
);
}

View File

@ -14,8 +14,8 @@ class HTMLPurifier_HTMLModule_TargetNoopenerTest extends HTMLPurifier_HTMLModule
public function testNoreferrer()
{
$this->assertResult(
'<a href="http://google.com" target="_blank">x</a>',
'<a href="http://google.com" target="_blank" rel="noopener">x</a>'
'<a href="https://google.com" target="_blank">x</a>',
'<a href="https://google.com" target="_blank" rel="noopener">x</a>'
);
}
@ -23,8 +23,8 @@ class HTMLPurifier_HTMLModule_TargetNoopenerTest extends HTMLPurifier_HTMLModule
{
$this->config->set('Attr.AllowedRel', 'noopener');
$this->assertResult(
'<a href="http://google.com" target="_blank" rel="noopener">x</a>',
'<a href="http://google.com" target="_blank" rel="noopener">x</a>'
'<a href="https://google.com" target="_blank" rel="noopener">x</a>',
'<a href="https://google.com" target="_blank" rel="noopener">x</a>'
);
}
@ -32,16 +32,16 @@ class HTMLPurifier_HTMLModule_TargetNoopenerTest extends HTMLPurifier_HTMLModule
{
$this->config->set('HTML.TargetBlank', true);
$this->assertResult(
'<a href="http://google.com">x</a>',
'<a href="http://google.com" target="_blank" rel="noopener">x</a>'
'<a href="https://google.com">x</a>',
'<a href="https://google.com" target="_blank" rel="noopener">x</a>'
);
}
public function testNoTarget()
{
$this->assertResult(
'<a href="http://google.com">x</a>',
'<a href="http://google.com">x</a>'
'<a href="https://google.com">x</a>',
'<a href="https://google.com">x</a>'
);
}

View File

@ -14,8 +14,8 @@ class HTMLPurifier_HTMLModule_TargetNoreferrerTest extends HTMLPurifier_HTMLModu
public function testNoreferrer()
{
$this->assertResult(
'<a href="http://google.com" target="_blank">x</a>',
'<a href="http://google.com" target="_blank" rel="noreferrer">x</a>'
'<a href="https://google.com" target="_blank">x</a>',
'<a href="https://google.com" target="_blank" rel="noreferrer">x</a>'
);
}
@ -23,8 +23,8 @@ class HTMLPurifier_HTMLModule_TargetNoreferrerTest extends HTMLPurifier_HTMLModu
{
$this->config->set('Attr.AllowedRel', 'noreferrer');
$this->assertResult(
'<a href="http://google.com" target="_blank" rel="noreferrer">x</a>',
'<a href="http://google.com" target="_blank" rel="noreferrer">x</a>'
'<a href="https://google.com" target="_blank" rel="noreferrer">x</a>',
'<a href="https://google.com" target="_blank" rel="noreferrer">x</a>'
);
}
@ -32,16 +32,16 @@ class HTMLPurifier_HTMLModule_TargetNoreferrerTest extends HTMLPurifier_HTMLModu
{
$this->config->set('HTML.TargetBlank', true);
$this->assertResult(
'<a href="http://google.com">x</a>',
'<a href="http://google.com" target="_blank" rel="noreferrer">x</a>'
'<a href="https://google.com">x</a>',
'<a href="https://google.com" target="_blank" rel="noreferrer">x</a>'
);
}
public function testNoTarget()
{
$this->assertResult(
'<a href="http://google.com">x</a>',
'<a href="http://google.com">x</a>'
'<a href="https://google.com">x</a>',
'<a href="https://google.com">x</a>'
);
}

View File

@ -3,6 +3,6 @@ HTML.AllowedElements = b,i,p,a
HTML.AllowedAttributes = a.href,*.id
--HTML--
<p>Par.</p>
<p>Para<a href="http://google.com/">gr</a>aph</p>
<p>Para<a href="https://google.com/">gr</a>aph</p>
Text<b>Bol<i>d</i></b>
--# vim: et sw=4 sts=4

View File

@ -2,5 +2,5 @@
HTML.SafeObject = true
Output.FlashCompat = true
--HTML--
<object width="425" height="350" data="http://www.youtube.com/v/BdU--T8rLns" type="application/x-shockwave-flash"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="http://www.youtube.com/v/BdU--T8rLns" /><param name="wmode" value="window" /></object>
<object width="425" height="350" data="https://www.youtube.com/v/BdU--T8rLns" type="application/x-shockwave-flash"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="https://www.youtube.com/v/BdU--T8rLns" /><param name="wmode" value="window" /></object>
--# vim: et sw=4 sts=4

View File

@ -5,8 +5,8 @@ URI.Munge = "/redirect?s=%s&t=%t&r=%r&n=%n&m=%m&p=%p"
URI.MungeSecretKey = "foo"
URI.MungeResources = true
--HTML--
<a href="http://example.com">Link</a>
<img src="http://example.com" style="background-image:url(http://example.com);" alt="example.com" />
<a href="https://example.com">Link</a>
<img src="https://example.com" style="background-image:url(https://example.com);" alt="example.com" />
--EXPECT--
<a href="/redirect?s=http%3A%2F%2Fexample.com&amp;t=c763c4a30204eee8470a3292e0f0cd91a639654d039d45f1495a50207847e954&amp;r=&amp;n=a&amp;m=href&amp;p=">Link</a>
<img src="/redirect?s=http%3A%2F%2Fexample.com&amp;t=c763c4a30204eee8470a3292e0f0cd91a639654d039d45f1495a50207847e954&amp;r=1&amp;n=img&amp;m=src&amp;p=" style="background-image:url(&quot;/redirect?s=http%3A%2F%2Fexample.com&amp;t=c763c4a30204eee8470a3292e0f0cd91a639654d039d45f1495a50207847e954&amp;r=1&amp;n=img&amp;m=style&amp;p=background-image&quot;);" alt="example.com" />

View File

@ -8,11 +8,11 @@ URI.AllowedSchemes = http,ftp,file
<a href="///google.com">foo</a>
<a href="////google.com">foo</a>
<a href="http:google.com">foo</a>
<a href="http:/google.com">foo</a>
<a href="http://google.com">foo</a>
<a href="http:///google.com">foo</a>
<a href="http:////google.com">foo</a>
<a href="https:google.com">foo</a>
<a href="https:/google.com">foo</a>
<a href="https://google.com">foo</a>
<a href="https:///google.com">foo</a>
<a href="https:////google.com">foo</a>
<a href="ftp:google.com">foo</a>
<a href="ftp:/google.com">foo</a>

View File

@ -1,8 +1,8 @@
--INI--
HTML.SafeIframe = true
URI.SafeIframeRegexp = "%^http://maps.google.com/%"
URI.SafeIframeRegexp = "%^https://maps.google.com/%"
--HTML--
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/?ie=UTF8&amp;ll=37.0625,-95.677068&amp;spn=24.455808,37.353516&amp;z=4&amp;output=embed"></iframe>
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/?ie=UTF8&amp;ll=37.0625,-95.677068&amp;spn=24.455808,37.353516&amp;z=4&amp;output=embed"></iframe>
--EXPECT--
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/?ie=UTF8&amp;ll=37.0625,-95.677068&amp;spn=24.455808,37.353516&amp;z=4&amp;output=embed"></iframe>
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/?ie=UTF8&amp;ll=37.0625,-95.677068&amp;spn=24.455808,37.353516&amp;z=4&amp;output=embed"></iframe>
--# vim: et sw=4 sts=4

View File

@ -1,7 +1,7 @@
--INI--
HTML.SafeIframe = true
--HTML--
<iframe src="http://www.example.com/"></iframe>
<iframe src="https://www.example.com/"></iframe>
--EXPECT--
<iframe></iframe>
--# vim: et sw=4 sts=4

View File

@ -1,8 +1,8 @@
--INI--
HTML.SafeIframe = true
URI.SafeIframeRegexp = "%^http://www.youtube.com/embed/%"
URI.SafeIframeRegexp = "%^https://www.youtube.com/embed/%"
--HTML--
<iframe title="YouTube video player" width="480" height="390" src="http://www.youtube.com/embed/RVtEQxH7PWA" frameborder="0" allowfullscreen></iframe>
<iframe title="YouTube video player" width="480" height="390" src="https://www.youtube.com/embed/RVtEQxH7PWA" frameborder="0" allowfullscreen></iframe>
--EXPECT--
<iframe title="YouTube video player" width="480" height="390" src="http://www.youtube.com/embed/RVtEQxH7PWA" frameborder="0"></iframe>
<iframe title="YouTube video player" width="480" height="390" src="https://www.youtube.com/embed/RVtEQxH7PWA" frameborder="0"></iframe>
--# vim: et sw=4 sts=4

View File

@ -1,14 +1,14 @@
--INI--
HTML.SafeIframe = true
URI.SafeIframeRegexp = "%(^http://www.example.com/|^https?://dev.example.com/)%"
URI.SafeIframeRegexp = "%(^https://www.example.com/|^https?://dev.example.com/)%"
--HTML--
<iframe src="http://www.example.com/"></iframe>
<iframe src="http://malicious.host.com/?http://www.example.com/"></iframe>
<iframe src="http://dev.example.com/"></iframe>
<iframe src="https://www.example.com/"></iframe>
<iframe src="https://malicious.host.com/?https://www.example.com/"></iframe>
<iframe src="https://dev.example.com/"></iframe>
<iframe src="https://dev.example.com/"></iframe>
--EXPECT--
<iframe src="http://www.example.com/"></iframe>
<iframe src="https://www.example.com/"></iframe>
<iframe></iframe>
<iframe src="http://dev.example.com/"></iframe>
<iframe src="https://dev.example.com/"></iframe>
<iframe src="https://dev.example.com/"></iframe>
--# vim: et sw=4 sts=4

View File

@ -6,7 +6,7 @@ HTML.SafeEmbed = true
URI.Munge = "/redirect.php?url=%s&check=%t"
URI.MungeSecretKey = "foo"
--HTML--
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/Oq3FV_zdyy0&hl=en"></param><embed src="http://www.youtube.com/v/Oq3FV_zdyy0&hl=en" type="application/x-shockwave-flash" width="425" height="344"></embed></object>
<object width="425" height="344"><param name="movie" value="https://www.youtube.com/v/Oq3FV_zdyy0&hl=en"></param><embed src="https://www.youtube.com/v/Oq3FV_zdyy0&hl=en" type="application/x-shockwave-flash" width="425" height="344"></embed></object>
--EXPECT--
<object width="425" height="344" data="http://www.youtube.com/v/Oq3FV_zdyy0&amp;hl=en" type="application/x-shockwave-flash"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="http://www.youtube.com/v/Oq3FV_zdyy0&amp;hl=en" /><embed src="http://www.youtube.com/v/Oq3FV_zdyy0&amp;hl=en" type="application/x-shockwave-flash" width="425" height="344" allowscriptaccess="never" allownetworking="internal" /></object>
<object width="425" height="344" data="https://www.youtube.com/v/Oq3FV_zdyy0&amp;hl=en" type="application/x-shockwave-flash"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="https://www.youtube.com/v/Oq3FV_zdyy0&amp;hl=en" /><embed src="https://www.youtube.com/v/Oq3FV_zdyy0&amp;hl=en" type="application/x-shockwave-flash" width="425" height="344" allowscriptaccess="never" allownetworking="internal" /></object>
--# vim: et sw=4 sts=4

View File

@ -2,7 +2,7 @@
HTML.SafeObject = true
HTML.SafeEmbed = true
--HTML--
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/Oq3FV_zdyy0&hl=en"></param><embed src="http://www.youtube.com/v/Oq3FV_zdyy0&hl=en" type="application/x-shockwave-flash" width="425" height="344"></embed></object>
<object width="425" height="344"><param name="movie" value="https://www.youtube.com/v/Oq3FV_zdyy0&hl=en"></param><embed src="https://www.youtube.com/v/Oq3FV_zdyy0&hl=en" type="application/x-shockwave-flash" width="425" height="344"></embed></object>
--EXPECT--
<object width="425" height="344" data="http://www.youtube.com/v/Oq3FV_zdyy0&amp;hl=en" type="application/x-shockwave-flash"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="http://www.youtube.com/v/Oq3FV_zdyy0&amp;hl=en" /><embed src="http://www.youtube.com/v/Oq3FV_zdyy0&amp;hl=en" type="application/x-shockwave-flash" width="425" height="344" allowscriptaccess="never" allownetworking="internal" /></object>
<object width="425" height="344" data="https://www.youtube.com/v/Oq3FV_zdyy0&amp;hl=en" type="application/x-shockwave-flash"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="https://www.youtube.com/v/Oq3FV_zdyy0&amp;hl=en" /><embed src="https://www.youtube.com/v/Oq3FV_zdyy0&amp;hl=en" type="application/x-shockwave-flash" width="425" height="344" allowscriptaccess="never" allownetworking="internal" /></object>
--# vim: et sw=4 sts=4

View File

@ -4,9 +4,9 @@ return !function_exists('hash_hmac');
URI.Munge = "/redirect.php?url=%s&check=%t"
URI.MungeSecretKey = "foo"
--HTML--
<a href="http://localhost">foo</a>
<img src="http://localhost" alt="local" />
<a href="https://localhost">foo</a>
<img src="https://localhost" alt="local" />
--EXPECT--
<a href="/redirect.php?url=http%3A%2F%2Flocalhost&amp;check=c0efad89696082f5cb925d28636b0f4260f346391c92c70c8e9eba72591c2a73">foo</a>
<img src="http://localhost" alt="local" />
<img src="https://localhost" alt="local" />
--# vim: et sw=4 sts=4

View File

@ -12,8 +12,8 @@ class HTMLPurifier_Injector_DisplayLinkURITest extends HTMLPurifier_InjectorHarn
public function testBasicLink()
{
$this->assertResult(
'<a href="http://malware.example.com">Don\'t go here!</a>',
'<a>Don\'t go here!</a> (http://malware.example.com)'
'<a href="https://malware.example.com">Don\'t go here!</a>',
'<a>Don\'t go here!</a> (https://malware.example.com)'
);
}
@ -27,8 +27,8 @@ class HTMLPurifier_Injector_DisplayLinkURITest extends HTMLPurifier_InjectorHarn
public function testEmptyText()
{
$this->assertResult(
'<a href="http://malware.example.com"></a>',
'<a></a> (http://malware.example.com)'
'<a href="https://malware.example.com"></a>',
'<a></a> (https://malware.example.com)'
);
}

View File

@ -12,31 +12,31 @@ class HTMLPurifier_Injector_LinkifyTest extends HTMLPurifier_InjectorHarness
public function testLinkifyURLInRootNode()
{
$this->assertResult(
'http://example.com',
'<a href="http://example.com">http://example.com</a>'
'https://example.com',
'<a href="https://example.com">https://example.com</a>'
);
}
public function testLinkifyURLInInlineNode()
{
$this->assertResult(
'<b>http://example.com</b>',
'<b><a href="http://example.com">http://example.com</a></b>'
'<b>https://example.com</b>',
'<b><a href="https://example.com">https://example.com</a></b>'
);
}
public function testBasicUsageCase()
{
$this->assertResult(
'This URL http://example.com is what you need',
'This URL <a href="http://example.com">http://example.com</a> is what you need'
'This URL https://example.com is what you need',
'This URL <a href="https://example.com">https://example.com</a> is what you need'
);
}
public function testIgnoreURLInATag()
{
$this->assertResult(
'<a>http://example.com/</a>'
'<a>https://example.com/</a>'
);
}
@ -44,20 +44,20 @@ class HTMLPurifier_Injector_LinkifyTest extends HTMLPurifier_InjectorHarness
{
$this->config->set('HTML.Allowed', 'b');
$this->expectError('Cannot enable Linkify injector because a is not allowed');
$this->assertResult('http://example.com/');
$this->assertResult('https://example.com/');
}
public function testExcludes()
{
$this->assertResult('<a><span>http://example.com</span></a>');
$this->assertResult('<a><span>https://example.com</span></a>');
}
public function testRegexIsSmart()
{
$this->assertResult('http://example.com/foo.', '<a href="http://example.com/foo">http://example.com/foo</a>.');
$this->assertResult('“http://example.com/foo”', '“<a href="http://example.com/foo">http://example.com/foo</a>”');
$this->assertResult('“http://example.com”', '“<a href="http://example.com">http://example.com</a>”');
$this->assertResult('(http://example.com/f(o)o)', '(<a href="http://example.com/f(o)o">http://example.com/f(o)o</a>)');
$this->assertResult('https://example.com/foo.', '<a href="https://example.com/foo">https://example.com/foo</a>.');
$this->assertResult('“https://example.com/foo”', '“<a href="https://example.com/foo">https://example.com/foo</a>”');
$this->assertResult('“https://example.com”', '“<a href="https://example.com">https://example.com</a>”');
$this->assertResult('(https://example.com/f(o)o)', '(<a href="https://example.com/f(o)o">https://example.com/f(o)o</a>)');
}
}

View File

@ -105,14 +105,14 @@ class HTMLPurifier_Injector_RemoveEmptyTest extends HTMLPurifier_InjectorHarness
public function testNoRemoveIframe()
{
$this->config->set('HTML.SafeIframe', true);
$this->assertResult('<iframe src="http://google.com"></iframe>', '');
$this->assertResult('<iframe src="https://google.com"></iframe>', '');
}
public function testRemoveDisallowedIframe()
{
$this->config->set('HTML.SafeIframe', true);
$this->config->set('URI.SafeIframeRegexp', '%^http://www.youtube.com/embed/%');
$this->assertResult('<iframe src="http://google.com"></iframe>', '');
$this->config->set('URI.SafeIframeRegexp', '%^https://www.youtube.com/embed/%');
$this->assertResult('<iframe src="https://google.com"></iframe>', '');
}
}

View File

@ -48,8 +48,8 @@ class HTMLPurifier_LanguageTest extends HTMLPurifier_Harness
$lang->messages['LanguageTest: Element info'] = 'Element Token: $1.Name, $1.Serialized, $1.Compact, $1.Line';
$lang->messages['LanguageTest: Data info'] = 'Data Token: $1.Data, $1.Serialized, $1.Compact, $1.Line';
$this->assertIdentical($lang->formatMessage('LanguageTest: Element info',
array(1=>new HTMLPurifier_Token_Start('a', array('href'=>'http://example.com'), 18))),
'Element Token: a, <a href="http://example.com">, <a>, 18');
array(1=>new HTMLPurifier_Token_Start('a', array('href'=>'https://example.com'), 18))),
'Element Token: a, <a href="https://example.com">, <a>, 18');
$this->assertIdentical($lang->formatMessage('LanguageTest: Data info',
array(1=>new HTMLPurifier_Token_Text('data>', 23))),
'Data Token: data>, data&gt;, data&gt;, 23');

View File

@ -179,8 +179,8 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness
$this->assertExtractBody(
'<?xml version="1.0"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>xyz</title>
</head>
@ -627,8 +627,8 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness
public function test_tokenizeHTML_emptyTagWithSlashInAttribute()
{
$this->assertTokenization(
'<param name="src" value="http://example.com/video.wmv" />',
array( new HTMLPurifier_Token_Empty('param', array('name' => 'src', 'value' => 'http://example.com/video.wmv')) )
'<param name="src" value="https://example.com/video.wmv" />',
array( new HTMLPurifier_Token_Empty('param', array('name' => 'src', 'value' => 'https://example.com/video.wmv')) )
);
}

View File

@ -46,7 +46,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_Str
{
$this->config->set('HTML.Allowed', 'a,p');
$this->expectError('Cannot enable Linkify injector because a.href is not allowed');
$this->assertResult('<p>http://example.com</p>');
$this->assertResult('<p>https://example.com</p>');
}
public function testOnlyAutoParagraph()
@ -60,62 +60,62 @@ class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_Str
public function testParagraphWrappingOnlyLink()
{
$this->assertResult(
'http://example.com',
'<p><a href="http://example.com">http://example.com</a></p>'
'https://example.com',
'<p><a href="https://example.com">https://example.com</a></p>'
);
}
public function testParagraphWrappingNodeContainingLink()
{
$this->assertResult(
'<b>http://example.com</b>',
'<p><b><a href="http://example.com">http://example.com</a></b></p>'
'<b>https://example.com</b>',
'<p><b><a href="https://example.com">https://example.com</a></b></p>'
);
}
public function testParagraphWrappingPoorlyFormedNodeContainingLink()
{
$this->assertResult(
'<b>http://example.com',
'<p><b><a href="http://example.com">http://example.com</a></b></p>'
'<b>https://example.com',
'<p><b><a href="https://example.com">https://example.com</a></b></p>'
);
}
public function testTwoParagraphsContainingOnlyOneLink()
{
$this->assertResult(
"http://example.com\n\nhttp://dev.example.com",
'<p><a href="http://example.com">http://example.com</a></p>
"https://example.com\n\nhttps://dev.example.com",
'<p><a href="https://example.com">https://example.com</a></p>
<p><a href="http://dev.example.com">http://dev.example.com</a></p>'
<p><a href="https://dev.example.com">https://dev.example.com</a></p>'
);
}
public function testParagraphNextToDivWithLinks()
{
$this->assertResult(
'http://example.com <div>http://example.com</div>',
'<p><a href="http://example.com">http://example.com</a> </p>
'https://example.com <div>https://example.com</div>',
'<p><a href="https://example.com">https://example.com</a> </p>
<div><a href="http://example.com">http://example.com</a></div>'
<div><a href="https://example.com">https://example.com</a></div>'
);
}
public function testRealisticLinkInSentence()
{
$this->assertResult(
'This URL http://example.com is what you need',
'<p>This URL <a href="http://example.com">http://example.com</a> is what you need</p>'
'This URL https://example.com is what you need',
'<p>This URL <a href="https://example.com">https://example.com</a> is what you need</p>'
);
}
public function testParagraphAfterLinkifiedURL()
{
$this->assertResult(
"http://google.com
"https://google.com
<b>b</b>",
"<p><a href=\"http://google.com\">http://google.com</a></p>
"<p><a href=\"https://google.com\">https://google.com</a></p>
<p><b>b</b></p>"
);

View File

@ -71,7 +71,7 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
public function testBasicURI()
{
$this->assertResult('<a href="http://www.google.com/">Google</a>');
$this->assertResult('<a href="https://www.google.com/">Google</a>');
}
public function testInvalidURI()

View File

@ -38,7 +38,7 @@ class HTMLPurifier_URIDefinitionTest extends HTMLPurifier_URIHarness
public function test_setupMemberVariables_collisionPrecedenceIsHostBaseScheme()
{
$this->config->set('URI.Host', $host = 'example.com');
$this->config->set('URI.Base', $base = 'http://sub.example.com/foo/bar.html');
$this->config->set('URI.Base', $base = 'https://sub.example.com/foo/bar.html');
$this->config->set('URI.DefaultScheme', 'ftp');
$def = new HTMLPurifier_URIDefinition();
$def->setup($this->config);
@ -57,7 +57,7 @@ class HTMLPurifier_URIDefinitionTest extends HTMLPurifier_URIHarness
public function test_setupMemberVariables_onlyBase()
{
$this->config->set('URI.Base', 'http://sub.example.com/foo/bar.html');
$this->config->set('URI.Base', 'https://sub.example.com/foo/bar.html');
$def = new HTMLPurifier_URIDefinition();
$def->setup($this->config);
$this->assertIdentical($def->host, 'sub.example.com');

View File

@ -16,7 +16,7 @@ class HTMLPurifier_URIFilter_DisableExternalResourcesTest extends
{
$this->context->destroy('EmbeddedURI'); // undo setUp
$this->assertFiltering(
'http://example.com'
'https://example.com'
);
}

View File

@ -12,7 +12,7 @@ class HTMLPurifier_URIFilter_DisableExternalTest extends HTMLPurifier_URIFilterH
public function testRemoveExternal()
{
$this->assertFiltering(
'http://example.com', false
'https://example.com', false
);
}
@ -27,7 +27,7 @@ class HTMLPurifier_URIFilter_DisableExternalTest extends HTMLPurifier_URIFilterH
{
$this->config->set('URI.Host', 'example.com');
$this->assertFiltering(
'http://example.com'
'https://example.com'
);
}
@ -35,7 +35,7 @@ class HTMLPurifier_URIFilter_DisableExternalTest extends HTMLPurifier_URIFilterH
{
$this->config->set('URI.Host', 'example.com');
$this->assertFiltering(
'http://www.example.com'
'https://www.example.com'
);
}
@ -43,15 +43,15 @@ class HTMLPurifier_URIFilter_DisableExternalTest extends HTMLPurifier_URIFilterH
{
$this->config->set('URI.Host', 'www.example.com');
$this->assertFiltering(
'http://example.com', false
'https://example.com', false
);
}
public function testBaseAsHost()
{
$this->config->set('URI.Base', 'http://www.example.com/foo/bar');
$this->config->set('URI.Base', 'https://www.example.com/foo/bar');
$this->assertFiltering(
'http://www.example.com/baz'
'https://www.example.com/baz'
);
}

View File

@ -12,20 +12,20 @@ class HTMLPurifier_URIFilter_HostBlacklistTest extends HTMLPurifier_URIFilterHar
public function testRejectBlacklistedHost()
{
$this->config->set('URI.HostBlacklist', 'example.com');
$this->assertFiltering('http://example.com', false);
$this->assertFiltering('https://example.com', false);
}
public function testRejectBlacklistedHostThoughNotTrue()
{
// maybe this behavior should change
$this->config->set('URI.HostBlacklist', 'example.com');
$this->assertFiltering('http://example.comcast.com', false);
$this->assertFiltering('https://example.comcast.com', false);
}
public function testPreserveNonBlacklistedHost()
{
$this->config->set('URI.HostBlacklist', 'example.com');
$this->assertFiltering('http://google.com');
$this->assertFiltering('https://google.com');
}
}

View File

@ -10,7 +10,7 @@ class HTMLPurifier_URIFilter_MakeAbsoluteTest extends HTMLPurifier_URIFilterHarn
$this->setBase();
}
public function setBase($base = 'http://example.com/foo/bar.html?q=s#frag')
public function setBase($base = 'https://example.com/foo/bar.html?q=s#frag')
{
$this->config->set('URI.Base', $base);
}
@ -19,17 +19,17 @@ class HTMLPurifier_URIFilter_MakeAbsoluteTest extends HTMLPurifier_URIFilterHarn
public function testPreserveAbsolute()
{
$this->assertFiltering('http://example.com/foo.html');
$this->assertFiltering('https://example.com/foo.html');
}
public function testFilterBlank()
{
$this->assertFiltering('', 'http://example.com/foo/bar.html?q=s');
$this->assertFiltering('', 'https://example.com/foo/bar.html?q=s');
}
public function testFilterEmptyPath()
{
$this->assertFiltering('?q=s#frag', 'http://example.com/foo/bar.html?q=s#frag');
$this->assertFiltering('?q=s#frag', 'https://example.com/foo/bar.html?q=s#frag');
}
public function testPreserveAltScheme()
@ -44,67 +44,67 @@ class HTMLPurifier_URIFilter_MakeAbsoluteTest extends HTMLPurifier_URIFilterHarn
public function testFilterIgnoreHTTPSpecialCase()
{
$this->assertFiltering('http:/', 'http://example.com/');
$this->assertFiltering('https:/', 'https://example.com/');
}
public function testFilterAbsolutePath()
{
$this->assertFiltering('/foo.txt', 'http://example.com/foo.txt');
$this->assertFiltering('/foo.txt', 'https://example.com/foo.txt');
}
public function testFilterRelativePath()
{
$this->assertFiltering('baz.txt', 'http://example.com/foo/baz.txt');
$this->assertFiltering('baz.txt', 'https://example.com/foo/baz.txt');
}
public function testFilterRelativePathWithInternalDot()
{
$this->assertFiltering('./baz.txt', 'http://example.com/foo/baz.txt');
$this->assertFiltering('./baz.txt', 'https://example.com/foo/baz.txt');
}
public function testFilterRelativePathWithEndingDot()
{
$this->assertFiltering('baz/.', 'http://example.com/foo/baz/');
$this->assertFiltering('baz/.', 'https://example.com/foo/baz/');
}
public function testFilterRelativePathDot()
{
$this->assertFiltering('.', 'http://example.com/foo/');
$this->assertFiltering('.', 'https://example.com/foo/');
}
public function testFilterRelativePathMultiDot()
{
$this->assertFiltering('././foo/./bar/.././baz', 'http://example.com/foo/foo/baz');
$this->assertFiltering('././foo/./bar/.././baz', 'https://example.com/foo/foo/baz');
}
public function testFilterAbsolutePathWithDot()
{
$this->assertFiltering('/./foo', 'http://example.com/foo');
$this->assertFiltering('/./foo', 'https://example.com/foo');
}
public function testFilterAbsolutePathWithMultiDot()
{
$this->assertFiltering('/./foo/../bar/.', 'http://example.com/bar/');
$this->assertFiltering('/./foo/../bar/.', 'https://example.com/bar/');
}
public function testFilterRelativePathWithInternalDotDot()
{
$this->assertFiltering('../baz.txt', 'http://example.com/baz.txt');
$this->assertFiltering('../baz.txt', 'https://example.com/baz.txt');
}
public function testFilterRelativePathWithEndingDotDot()
{
$this->assertFiltering('..', 'http://example.com/');
$this->assertFiltering('..', 'https://example.com/');
}
public function testFilterRelativePathTooManyDotDots()
{
$this->assertFiltering('../../', 'http://example.com/');
$this->assertFiltering('../../', 'https://example.com/');
}
public function testFilterAppendingQueryAndFragment()
{
$this->assertFiltering('/foo.php?q=s#frag', 'http://example.com/foo.php?q=s#frag');
$this->assertFiltering('/foo.php?q=s#frag', 'https://example.com/foo.php?q=s#frag');
}
// edge cases below
@ -154,16 +154,16 @@ class HTMLPurifier_URIFilter_MakeAbsoluteTest extends HTMLPurifier_URIFilterHarn
public function testRemoveJavaScriptWithEmbeddedLink()
{
// credits: NykO18
$this->setBase('http://www.example.com/');
$this->assertFiltering('javascript: window.location = \'http://www.example.com\';', false);
$this->setBase('https://www.example.com/');
$this->assertFiltering('javascript: window.location = \'https://www.example.com\';', false);
}
// miscellaneous
public function testFilterDomainWithNoSlash()
{
$this->setBase('http://example.com');
$this->assertFiltering('foo', 'http://example.com/foo');
$this->setBase('https://example.com');
$this->assertFiltering('foo', 'https://example.com/foo');
}
// error case

View File

@ -9,7 +9,7 @@ class HTMLPurifier_URIFilter_MungeTest extends HTMLPurifier_URIFilterHarness
$this->filter = new HTMLPurifier_URIFilter_Munge();
}
protected function setMunge($uri = 'http://www.google.com/url?q=%s')
protected function setMunge($uri = 'https://www.google.com/url?q=%s')
{
$this->config->set('URI.Munge', $uri);
}
@ -26,8 +26,8 @@ class HTMLPurifier_URIFilter_MungeTest extends HTMLPurifier_URIFilterHarness
{
$this->setMunge();
$this->assertFiltering(
'http://www.example.com/',
'http://www.google.com/url?q=http%3A%2F%2Fwww.example.com%2F'
'https://www.example.com/',
'https://www.google.com/url?q=http%3A%2F%2Fwww.example.com%2F'
);
}
@ -36,7 +36,7 @@ class HTMLPurifier_URIFilter_MungeTest extends HTMLPurifier_URIFilterHarness
$this->setMunge('/r?tagname=%n&url=%s');
$token = new HTMLPurifier_Token_Start('a');
$this->context->register('CurrentToken', $token);
$this->assertFiltering('http://google.com', '/r?tagname=a&url=http%3A%2F%2Fgoogle.com');
$this->assertFiltering('https://google.com', '/r?tagname=a&url=http%3A%2F%2Fgoogle.com');
}
public function testMungeReplaceAttribute()
@ -44,7 +44,7 @@ class HTMLPurifier_URIFilter_MungeTest extends HTMLPurifier_URIFilterHarness
$this->setMunge('/r?attr=%m&url=%s');
$attr = 'href';
$this->context->register('CurrentAttr', $attr);
$this->assertFiltering('http://google.com', '/r?attr=href&url=http%3A%2F%2Fgoogle.com');
$this->assertFiltering('https://google.com', '/r?attr=href&url=http%3A%2F%2Fgoogle.com');
}
public function testMungeReplaceResource()
@ -52,7 +52,7 @@ class HTMLPurifier_URIFilter_MungeTest extends HTMLPurifier_URIFilterHarness
$this->setMunge('/r?embeds=%r&url=%s');
$embeds = false;
$this->context->register('EmbeddedURI', $embeds);
$this->assertFiltering('http://google.com', '/r?embeds=&url=http%3A%2F%2Fgoogle.com');
$this->assertFiltering('https://google.com', '/r?embeds=&url=http%3A%2F%2Fgoogle.com');
}
public function testMungeReplaceCSSProperty()
@ -60,7 +60,7 @@ class HTMLPurifier_URIFilter_MungeTest extends HTMLPurifier_URIFilterHarness
$this->setMunge('/r?property=%p&url=%s');
$property = 'background';
$this->context->register('CurrentCSSProperty', $property);
$this->assertFiltering('http://google.com', '/r?property=background&url=http%3A%2F%2Fgoogle.com');
$this->assertFiltering('https://google.com', '/r?property=background&url=http%3A%2F%2Fgoogle.com');
}
public function testIgnoreEmbedded()
@ -68,7 +68,7 @@ class HTMLPurifier_URIFilter_MungeTest extends HTMLPurifier_URIFilterHarness
$this->setMunge();
$embeds = true;
$this->context->register('EmbeddedURI', $embeds);
$this->assertFiltering('http://example.com');
$this->assertFiltering('https://example.com');
}
public function testProcessEmbedded()
@ -77,7 +77,7 @@ class HTMLPurifier_URIFilter_MungeTest extends HTMLPurifier_URIFilterHarness
$this->config->set('URI.MungeResources', true);
$embeds = true;
$this->context->register('EmbeddedURI', $embeds);
$this->assertFiltering('http://www.example.com/', 'http://www.google.com/url?q=http%3A%2F%2Fwww.example.com%2F');
$this->assertFiltering('https://www.example.com/', 'https://www.google.com/url?q=http%3A%2F%2Fwww.example.com%2F');
}
public function testPreserveRelative()
@ -103,13 +103,13 @@ class HTMLPurifier_URIFilter_MungeTest extends HTMLPurifier_URIFilterHarness
if (!$this->setSecureMunge()) return;
$embedded = true;
$this->context->register('EmbeddedURI', $embedded);
$this->assertFiltering('http://google.com');
$this->assertFiltering('https://google.com');
}
public function testSecureMungeStandard()
{
if (!$this->setSecureMunge()) return;
$this->assertFiltering('http://google.com', '/redirect.php?url=http%3A%2F%2Fgoogle.com&checksum=46267a796aca0ea5839f24c4c97ad2648373a4eca31b1c0d1fa7c7ff26798f79');
$this->assertFiltering('https://google.com', '/redirect.php?url=http%3A%2F%2Fgoogle.com&checksum=46267a796aca0ea5839f24c4c97ad2648373a4eca31b1c0d1fa7c7ff26798f79');
}
public function testSecureMungeIgnoreUnknownSchemes()
@ -129,25 +129,25 @@ class HTMLPurifier_URIFilter_MungeTest extends HTMLPurifier_URIFilterHarness
{
if (!$this->setSecureMunge()) return;
$this->setMunge('/links/%s/%t');
$this->assertFiltering('http://google.com', '/links/http%3A%2F%2Fgoogle.com/46267a796aca0ea5839f24c4c97ad2648373a4eca31b1c0d1fa7c7ff26798f79');
$this->assertFiltering('https://google.com', '/links/http%3A%2F%2Fgoogle.com/46267a796aca0ea5839f24c4c97ad2648373a4eca31b1c0d1fa7c7ff26798f79');
}
public function testMungeIgnoreSameDomain()
{
$this->setMunge('http://example.com/%s');
$this->assertFiltering('http://example.com/foobar');
$this->setMunge('https://example.com/%s');
$this->assertFiltering('https://example.com/foobar');
}
public function testMungeIgnoreSameDomainInsecureToSecure()
{
$this->setMunge('http://example.com/%s');
$this->setMunge('https://example.com/%s');
$this->assertFiltering('https://example.com/foobar');
}
public function testMungeIgnoreSameDomainSecureToSecure()
{
$this->config->set('URI.Base', 'https://example.com');
$this->setMunge('http://example.com/%s');
$this->setMunge('https://example.com/%s');
$this->assertFiltering('https://example.com/foobar');
}
@ -155,14 +155,14 @@ class HTMLPurifier_URIFilter_MungeTest extends HTMLPurifier_URIFilterHarness
{
$this->config->set('URI.Base', 'https://example.com');
$this->setMunge('/%s');
$this->assertFiltering('http://example.com/foobar', '/http%3A%2F%2Fexample.com%2Ffoobar');
$this->assertFiltering('https://example.com/foobar', '/http%3A%2F%2Fexample.com%2Ffoobar');
}
public function testMungeIgnoresSourceHost()
{
$this->config->set('URI.Host', 'foo.example.com');
$this->setMunge('http://example.com/%s');
$this->assertFiltering('http://foo.example.com/bar');
$this->setMunge('https://example.com/%s');
$this->assertFiltering('https://foo.example.com/bar');
}
}

View File

@ -24,7 +24,7 @@ class HTMLPurifier_URIParserTest extends HTMLPurifier_Harness
public function testRegular()
{
$this->assertParsing(
'http://www.example.com/webhp?q=foo#result2',
'https://www.example.com/webhp?q=foo#result2',
'http', null, 'www.example.com', null, '/webhp', 'q=foo', 'result2'
);
}
@ -32,7 +32,7 @@ class HTMLPurifier_URIParserTest extends HTMLPurifier_Harness
public function testPortAndUsername()
{
$this->assertParsing(
'http://user@authority.part:80/now/the/path?query#fragment',
'https://user@authority.part:80/now/the/path?query#fragment',
'http', 'user', 'authority.part', 80, '/now/the/path', 'query', 'fragment'
);
}
@ -40,7 +40,7 @@ class HTMLPurifier_URIParserTest extends HTMLPurifier_Harness
public function testPercentEncoding()
{
$this->assertParsing(
'http://en.wikipedia.org/wiki/Clich%C3%A9',
'https://en.wikipedia.org/wiki/Clich%C3%A9',
'http', null, 'en.wikipedia.org', null, '/wiki/Clich%C3%A9', null, null
);
}
@ -48,7 +48,7 @@ class HTMLPurifier_URIParserTest extends HTMLPurifier_Harness
public function testEmptyQuery()
{
$this->assertParsing(
'http://www.example.com/?#',
'https://www.example.com/?#',
'http', null, 'www.example.com', null, '/', '', null
);
}
@ -56,7 +56,7 @@ class HTMLPurifier_URIParserTest extends HTMLPurifier_Harness
public function testEmptyPath()
{
$this->assertParsing(
'http://www.example.com',
'https://www.example.com',
'http', null, 'www.example.com', null, '', null, null
);
}
@ -80,7 +80,7 @@ class HTMLPurifier_URIParserTest extends HTMLPurifier_Harness
public function testIPv4Address()
{
$this->assertParsing(
'http://192.0.34.166/',
'https://192.0.34.166/',
'http', null, '192.0.34.166', null, '/', null, null
);
}
@ -88,7 +88,7 @@ class HTMLPurifier_URIParserTest extends HTMLPurifier_Harness
public function testFakeIPv4Address()
{
$this->assertParsing(
'http://333.123.32.123/',
'https://333.123.32.123/',
'http', null, '333.123.32.123', null, '/', null, null
);
}
@ -96,7 +96,7 @@ class HTMLPurifier_URIParserTest extends HTMLPurifier_Harness
public function testIPv6Address()
{
$this->assertParsing(
'http://[2001:db8::7]/c=GB?objectClass?one',
'https://[2001:db8::7]/c=GB?objectClass?one',
'http', null, '[2001:db8::7]', null, '/c=GB', 'objectClass?one', null
);
}
@ -104,7 +104,7 @@ class HTMLPurifier_URIParserTest extends HTMLPurifier_Harness
public function testInternationalizedDomainName()
{
$this->assertParsing(
"http://t\xC5\xABdali\xC5\x86.lv",
"https://t\xC5\xABdali\xC5\x86.lv",
'http', null, "t\xC5\xABdali\xC5\x86.lv", null, '', null, null
);
}
@ -112,7 +112,7 @@ class HTMLPurifier_URIParserTest extends HTMLPurifier_Harness
public function testInvalidPort()
{
$this->assertParsing(
'http://example.com:foobar',
'https://example.com:foobar',
'http', null, 'example.com', null, '', null, null
);
}
@ -120,7 +120,7 @@ class HTMLPurifier_URIParserTest extends HTMLPurifier_Harness
public function testPathAbsolute()
{
$this->assertParsing(
'http:/this/is/path',
'https:/this/is/path',
'http', null, null, null, '/this/is/path', null, null
);
}
@ -129,7 +129,7 @@ class HTMLPurifier_URIParserTest extends HTMLPurifier_Harness
{
// this should not be used but is allowed
$this->assertParsing(
'http:this/is/path',
'https:this/is/path',
'http', null, null, null, 'this/is/path', null, null
);
}
@ -137,7 +137,7 @@ class HTMLPurifier_URIParserTest extends HTMLPurifier_Harness
public function testPathEmpty()
{
$this->assertParsing(
'http:',
'https:',
'http', null, null, null, '', null, null
);
}
@ -153,7 +153,7 @@ class HTMLPurifier_URIParserTest extends HTMLPurifier_Harness
public function testMalformedTag()
{
$this->assertParsing(
'http://www.example.com/>',
'https://www.example.com/>',
'http', null, 'www.example.com', null, '/', null, null
);
}

View File

@ -32,37 +32,37 @@ class HTMLPurifier_URISchemeTest extends HTMLPurifier_URIHarness
public function test_http_regular()
{
$this->assertValidation(
'http://example.com/?s=q#fragment'
'https://example.com/?s=q#fragment'
);
}
public function test_http_uppercase()
{
$this->assertValidation(
'http://example.com/FOO'
'https://example.com/FOO'
);
}
public function test_http_removeDefaultPort()
{
$this->assertValidation(
'http://example.com:80',
'http://example.com'
'https://example.com:80',
'https://example.com'
);
}
public function test_http_removeUserInfo()
{
$this->assertValidation(
'http://bob@example.com',
'http://example.com'
'https://bob@example.com',
'https://example.com'
);
}
public function test_http_preserveNonDefaultPort()
{
$this->assertValidation(
'http://example.com:8080'
'https://example.com:8080'
);
}

View File

@ -51,7 +51,7 @@ class HTMLPurifier_URITest extends HTMLPurifier_URIHarness
{
$scheme_mock = $this->setUpSchemeMock('http');
$uri = $this->createURI('http:');
$uri = $this->createURI('https:');
$scheme_obj = $uri->getSchemeObj($this->config, $this->context);
$this->assertIdentical($scheme_obj, $scheme_mock);
@ -62,7 +62,7 @@ class HTMLPurifier_URITest extends HTMLPurifier_URIHarness
{
$this->setUpNoValidSchemes();
$uri = $this->createURI('http:');
$uri = $this->createURI('https:');
$result = $uri->getSchemeObj($this->config, $this->context);
$this->assertIdentical($result, false);
@ -107,7 +107,7 @@ class HTMLPurifier_URITest extends HTMLPurifier_URIHarness
public function test_toString_full()
{
$this->assertToString(
'http://bob@example.com:300/foo?bar=baz#fragment',
'https://bob@example.com:300/foo?bar=baz#fragment',
'http', 'bob', 'example.com', 300, '/foo', 'bar=baz', 'fragment'
);
}
@ -115,7 +115,7 @@ class HTMLPurifier_URITest extends HTMLPurifier_URIHarness
public function test_toString_scheme()
{
$this->assertToString(
'http:',
'https:',
'http', null, null, null, '', null, null
);
}
@ -167,32 +167,32 @@ class HTMLPurifier_URITest extends HTMLPurifier_URIHarness
public function test_validate_overlongPort()
{
$this->assertValidation('http://example.com:65536', 'http://example.com');
$this->assertValidation('https://example.com:65536', 'https://example.com');
}
public function test_validate_zeroPort()
{
$this->assertValidation('http://example.com:00', 'http://example.com');
$this->assertValidation('https://example.com:00', 'https://example.com');
}
public function test_validate_invalidHostThatLooksLikeIPv6()
{
$this->assertValidation('http://[2001:0db8:85z3:08d3:1319:8a2e:0370:7334]', '');
$this->assertValidation('https://[2001:0db8:85z3:08d3:1319:8a2e:0370:7334]', '');
}
public function test_validate_removeRedundantScheme()
{
$this->assertValidation('http:foo:/:', 'foo%3A/:');
$this->assertValidation('https:foo:/:', 'foo%3A/:');
}
public function test_validate_username()
{
$this->assertValidation("http://user\xE3\x91\x94:@foo.com", 'http://user%E3%91%94:@foo.com');
$this->assertValidation("https://user\xE3\x91\x94:@foo.com", 'https://user%E3%91%94:@foo.com');
}
public function test_validate_path_abempty()
{
$this->assertValidation("http://host/\xE3\x91\x94:", 'http://host/%E3%91%94:');
$this->assertValidation("https://host/\xE3\x91\x94:", 'https://host/%E3%91%94:');
}
public function test_validate_path_absolute()
@ -222,7 +222,7 @@ class HTMLPurifier_URITest extends HTMLPurifier_URIHarness
public function test_validate_path_empty()
{
$this->assertValidation('http://google.com');
$this->assertValidation('https://google.com');
}
}