mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-23 00:41:52 +00:00
Add support for encoded tel URI schemes. (#354)
This commit is contained in:
parent
becc9d40cf
commit
1424f17cf3
@ -37,7 +37,7 @@ class HTMLPurifier_URIScheme_tel extends HTMLPurifier_URIScheme
|
|||||||
// from phone number, EXCEPT for a leading plus sign.
|
// from phone number, EXCEPT for a leading plus sign.
|
||||||
$uri->path = preg_replace('/(?!^\+)[^\dx]/', '',
|
$uri->path = preg_replace('/(?!^\+)[^\dx]/', '',
|
||||||
// Normalize e(x)tension to lower-case
|
// Normalize e(x)tension to lower-case
|
||||||
str_replace('X', 'x', $uri->path));
|
str_replace('X', 'x', rawurldecode($uri->path)));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,8 @@ class HTMLPurifier_AttrDef_URITest extends HTMLPurifier_AttrDefHarness
|
|||||||
$this->assertDef('nntp://news.example.com/324234');
|
$this->assertDef('nntp://news.example.com/324234');
|
||||||
$this->assertDef('mailto:bob@example.com');
|
$this->assertDef('mailto:bob@example.com');
|
||||||
$this->assertDef('tel:+15555555555');
|
$this->assertDef('tel:+15555555555');
|
||||||
|
$this->assertDef('tel:+15555 555 555', 'tel:+15555555555');
|
||||||
|
$this->assertDef('tel:+15555%20555%20555', 'tel:+15555555555');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIntegrationWithPercentEncoder()
|
public function testIntegrationWithPercentEncoder()
|
||||||
|
@ -40,6 +40,8 @@ class HTMLPurifier_URIFilter_MakeAbsoluteTest extends HTMLPurifier_URIFilterHarn
|
|||||||
public function testPreserveAltSchemeWithTel()
|
public function testPreserveAltSchemeWithTel()
|
||||||
{
|
{
|
||||||
$this->assertFiltering('tel:+15555555555');
|
$this->assertFiltering('tel:+15555555555');
|
||||||
|
$this->assertFiltering('tel:+15555 555 555');
|
||||||
|
$this->assertFiltering('tel:+15555%20555%20555');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFilterIgnoreHTTPSpecialCase()
|
public function testFilterIgnoreHTTPSpecialCase()
|
||||||
|
@ -75,6 +75,10 @@ class HTMLPurifier_URIParserTest extends HTMLPurifier_Harness
|
|||||||
'tel:+1 (555) 555-5555',
|
'tel:+1 (555) 555-5555',
|
||||||
'tel', null, null, null, '+1 (555) 555-5555', null, null
|
'tel', null, null, null, '+1 (555) 555-5555', null, null
|
||||||
);
|
);
|
||||||
|
$this->assertParsing(
|
||||||
|
'tel:+1%20(555)%20555-5555',
|
||||||
|
'tel', null, null, null, '+1%20(555)%20555-5555', null, null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIPv4Address()
|
public function testIPv4Address()
|
||||||
|
@ -179,6 +179,13 @@ class HTMLPurifier_URISchemeTest extends HTMLPurifier_URIHarness
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_tel_with_url_encoding()
|
||||||
|
{
|
||||||
|
$this->assertValidation(
|
||||||
|
'tel:+1%20(555)%20555-5555', 'tel:+15555555555'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function test_tel_regular()
|
public function test_tel_regular()
|
||||||
{
|
{
|
||||||
$this->assertValidation(
|
$this->assertValidation(
|
||||||
|
Loading…
Reference in New Issue
Block a user