Permalink
Browse files

International tel URI supported via link alias. Extend unrestricted l…

…ink alias to all schemes.
  • Loading branch information...
netcarver committed May 24, 2012
1 parent 5ebb787 commit a565f37d203b38736f40465546df81d5d76b675d
Showing with 35 additions and 2 deletions.
  1. +5 −2 classTextile.php
  2. +30 −0 test/basic.yaml
View
@@ -1626,8 +1626,11 @@ function fLink($m)
// -------------------------------------------------------------
function getRefs($text)
{
- return preg_replace_callback("/^\[(.+)\]((?:http:\/\/|https:\/\/|\/)\S+)(?=\s|$)/Um",
- array(&$this, "refs"), $text);
+ if( $this->restricted )
+ $pattern = "/^\[(.+)\]((?:http:\/\/|https:\/\/|\/)\S+)(?=\s|$)/Um";
+ else
+ $pattern = "/^\[(.+)\]((?:http:\/\/|https:\/\/|tel:|file:|ftp:\/\/|sftp:\/\/|mailto:|callto:|\/)\S+)(?=\s|$)/Um";
+ return preg_replace_callback( $pattern, array(&$this, "refs"), $text);
}
// -------------------------------------------------------------
View
@@ -394,27 +394,45 @@ URI-Schemes :
"link with ftp":ftp://textileit.com
+ "link with ftp alias":uri-alias4
+
"link with sftp":sftp://foobar@textileit.com
"$":sftp://foobar@textileit.com
+ "link with sftp alias":uri-alias3
+
"link with file1":file://host.example.com/folder/file.ext
"$":file://host.example.com/folder/file.ext
"link with file2":file:///c:/folder/file.ext
+ "link with file alias":uri-alias2
+
"$":file:///c:/folder/file.ext
"link with tel":tel:123123123123123123-123
"$":tel:123123123123123123-123
+ "int tel":uri-alias1
+
"link with mailto":mailto:contact@textileit.com
+ "link with mailto alias":uri-alias6
+
"link with callto":callto:textileit.com
+ "link with callto alias":uri-alias5
+
"$":callto:textileit.com
+ [uri-alias1]tel:+123-(0)-123123123-123
+ [uri-alias2]file:///c:/folder/file.ext
+ [uri-alias3]sftp://foo@bar.net
+ [uri-alias4]ftp://foo@bar.net
+ [uri-alias5]callto:textileit.com
+ [uri-alias6]mailto:contact@textileit.com
expect : |
<p><a href="textileit.com">link with no scheme</a></p>
@@ -425,26 +443,38 @@ URI-Schemes :
<p><a href="ftp://textileit.com">link with ftp</a></p>
+ <p><a href="ftp://foo@bar.net">link with ftp alias</a></p>
+
<p><a href="sftp://foobar@textileit.com">link with sftp</a></p>
<p><a href="sftp://foobar@textileit.com">foobar@textileit.com</a></p>
+ <p><a href="sftp://foo@bar.net">link with sftp alias</a></p>
+
<p><a href="file://host.example.com/folder/file.ext">link with file1</a></p>
<p><a href="file://host.example.com/folder/file.ext">host.example.com/folder/file.ext</a></p>
<p><a href="file:/c%3A/folder/file.ext">link with file2</a></p>
+ <p><a href="file:/c%3A/folder/file.ext">link with file alias</a></p>
+
<p><a href="file:/c%3A/folder/file.ext">c:/folder/file.ext</a></p>
<p><a href="tel:123123123123123123-123">link with tel</a></p>
<p><a href="tel:123123123123123123-123">123123123123123123-123</a></p>
+ <p><a href="tel:%2B123-%280%29-123123123-123">int tel</a></p>
+
<p><a href="mailto:contact@textileit.com">link with mailto</a></p>
+ <p><a href="mailto:contact@textileit.com">link with mailto alias</a></p>
+
<p><a href="callto:textileit.com">link with callto</a></p>
+ <p><a href="callto:textileit.com">link with callto alias</a></p>
+
<p><a href="callto:textileit.com">textileit.com</a></p>
Self-Hyperlink :

0 comments on commit a565f37

Please sign in to comment.