mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-30 19:00:10 +02:00
Properly use HMAC for secure munging.
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
@@ -6,6 +6,6 @@ URI.MungeResources = true
|
||||
<a href="http://example.com">Link</a>
|
||||
<img src="http://example.com" style="background-image:url(http://example.com);" alt="example.com" />
|
||||
--EXPECT--
|
||||
<a href="/redirect?s=http%3A%2F%2Fexample.com&t=c15354f3953dfec262c55b1403067e0d045a3059&r=&n=a&m=href&p=">Link</a>
|
||||
<img src="/redirect?s=http%3A%2F%2Fexample.com&t=c15354f3953dfec262c55b1403067e0d045a3059&r=1&n=img&m=src&p=" style="background-image:url("/redirect?s=http%3A%2F%2Fexample.com&t=c15354f3953dfec262c55b1403067e0d045a3059&r=1&n=img&m=style&p=background-image");" alt="example.com" />
|
||||
<a href="/redirect?s=http%3A%2F%2Fexample.com&t=c763c4a30204eee8470a3292e0f0cd91a639654d039d45f1495a50207847e954&r=&n=a&m=href&p=">Link</a>
|
||||
<img src="/redirect?s=http%3A%2F%2Fexample.com&t=c763c4a30204eee8470a3292e0f0cd91a639654d039d45f1495a50207847e954&r=1&n=img&m=src&p=" style="background-image:url("/redirect?s=http%3A%2F%2Fexample.com&t=c763c4a30204eee8470a3292e0f0cd91a639654d039d45f1495a50207847e954&r=1&n=img&m=style&p=background-image");" alt="example.com" />
|
||||
--# vim: et sw=4 sts=4
|
||||
|
@@ -5,6 +5,6 @@ URI.MungeSecretKey = "foo"
|
||||
<a href="http://localhost">foo</a>
|
||||
<img src="http://localhost" alt="local" />
|
||||
--EXPECT--
|
||||
<a href="/redirect.php?url=http%3A%2F%2Flocalhost&check=8e8223ae8fac24561104180ea549c21fbd111be7">foo</a>
|
||||
<a href="/redirect.php?url=http%3A%2F%2Flocalhost&check=c0efad89696082f5cb925d28636b0f4260f346391c92c70c8e9eba72591c2a73">foo</a>
|
||||
<img src="http://localhost" alt="local" />
|
||||
--# vim: et sw=4 sts=4
|
||||
|
@@ -107,7 +107,7 @@ class HTMLPurifier_URIFilter_MungeTest extends HTMLPurifier_URIFilterHarness
|
||||
public function testSecureMungeStandard()
|
||||
{
|
||||
$this->setSecureMunge();
|
||||
$this->assertFiltering('http://google.com', '/redirect.php?url=http%3A%2F%2Fgoogle.com&checksum=0072e2f817fd2844825def74e54443debecf0892');
|
||||
$this->assertFiltering('http://google.com', '/redirect.php?url=http%3A%2F%2Fgoogle.com&checksum=46267a796aca0ea5839f24c4c97ad2648373a4eca31b1c0d1fa7c7ff26798f79');
|
||||
}
|
||||
|
||||
public function testSecureMungeIgnoreUnknownSchemes()
|
||||
@@ -127,7 +127,7 @@ class HTMLPurifier_URIFilter_MungeTest extends HTMLPurifier_URIFilterHarness
|
||||
{
|
||||
$this->setSecureMunge();
|
||||
$this->setMunge('/links/%s/%t');
|
||||
$this->assertFiltering('http://google.com', '/links/http%3A%2F%2Fgoogle.com/0072e2f817fd2844825def74e54443debecf0892');
|
||||
$this->assertFiltering('http://google.com', '/links/http%3A%2F%2Fgoogle.com/46267a796aca0ea5839f24c4c97ad2648373a4eca31b1c0d1fa7c7ff26798f79');
|
||||
}
|
||||
|
||||
public function testMungeIgnoreSameDomain()
|
||||
|
Reference in New Issue
Block a user