Skip to content

Commit

Permalink
[TASK] Add support for tel: in link href attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
derhansen authored and ohader committed Aug 8, 2021
1 parent e721fcd commit c5f1e2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Builder/CommonBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public function __construct()
$isHttpOrLocalUri = new Behavior\RegExpAttrValue('#^(https?://|/(?!/)|[^/:][^:]*$)#');
// + starting with `mailto:`
$isMailtoUri = new Behavior\RegExpAttrValue('#^mailto:#');
// + starting with `tel:`
$isTelUri = new Behavior\RegExpAttrValue('#^tel:#');

$this->globalAttrs = $this->createGlobalAttrs();
$this->srcAttr = (new Behavior\Attr('src', Behavior\Attr::MATCH_FIRST_VALUE))
Expand All @@ -62,7 +64,7 @@ public function __construct()
// @todo Add test for `srcset="media.png 1080w"`
->addValues($isHttpOrLocalUri);
$this->hrefAttr = (new Behavior\Attr('href', Behavior\Attr::MATCH_FIRST_VALUE))
->addValues($isHttpOrLocalUri, $isMailtoUri);
->addValues($isHttpOrLocalUri, $isMailtoUri, $isTelUri);
}

public function build(): Sanitizer
Expand Down
4 changes: 4 additions & 0 deletions tests/CommonBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ public function isSanitizedDataProvider(): array
'<a href="#anchor">anchor</a><a name="anchor">content</a>',
'<a href="#anchor">anchor</a><a name="anchor">content</a>',
],
'#055' => [
'<a href="tel:123456789">anchor</a>',
'<a href="tel:123456789">anchor</a>',
],
'#090' => [
'<p data-bool><span data-bool><strong data-bool>value</strong></span></p>',
'<p data-bool><span data-bool><strong data-bool>value</strong></span></p>'
Expand Down

0 comments on commit c5f1e2e

Please sign in to comment.