diff --git a/plugins/DirectionDetector/DirectionDetectorPlugin.php b/plugins/DirectionDetector/DirectionDetectorPlugin.php index 1473c386fa..4a38f390f1 100644 --- a/plugins/DirectionDetector/DirectionDetectorPlugin.php +++ b/plugins/DirectionDetector/DirectionDetectorPlugin.php @@ -81,6 +81,9 @@ class DirectionDetectorPlugin extends Plugin { * @return boolean */ public static function startsWithRTLCharacter($str){ + if (strlen($str) < 1) { + return false; + } if( is_array($cc = self::utf8ToUnicode(mb_substr($str, 0, 1, 'utf-8'))) ) $cc = $cc[0]; else diff --git a/plugins/OStatus/tests/FeedDiscoveryTest.php b/plugins/OStatus/tests/FeedDiscoveryTest.php index 3be4bf736c..ef17efe7cf 100644 --- a/plugins/OStatus/tests/FeedDiscoveryTest.php +++ b/plugins/OStatus/tests/FeedDiscoveryTest.php @@ -75,9 +75,10 @@ END; '
',
                            'http://example.com/feed/rss'),
+                     // This one can't resolve correctly; relative link is bogus.
                      array('http://example.com/relative/link3',
                            '',
-                           'http://example.com/feed/rss'),
+                           'http:/feed/rss'),
                      array('http://example.com/base/link1',
                            '',
                            'http://target.example.com/feed/rss'),
                      array('http://example.com/base/link2',
                            '',
                            'http://target.example.com/feed/rss'),
+                     // This one can't resolve; relative link is bogus.
                      array('http://example.com/base/link3',
                            '',
-                           'http://target.example.com/feed/rss'),
+                           'http:/feed/rss'),
                      // Trick question! There's a  but no href on it
                      array('http://example.com/relative/fauxbase',
                            '',
diff --git a/tests/URLDetectionTest.php b/tests/URLDetectionTest.php
index d83f9faf58..eac7ba3f5c 100644
--- a/tests/URLDetectionTest.php
+++ b/tests/URLDetectionTest.php
@@ -29,73 +29,73 @@ class URLDetectionTest extends PHPUnit_Framework_TestCase
                      array('not a link :: no way',
                            'not a link :: no way'),
                      array('link http://www.somesite.com/xyz/35637563@N00/52803365/ link',
-                           'link http://www.somesite.com/xyz/35637563@N00/52803365/ link'),
+                           'link http://www.somesite.com/xyz/35637563@N00/52803365/ link'),
                      array('http://127.0.0.1',
-                           'http://127.0.0.1'),
+                           'http://127.0.0.1'),
                      array('127.0.0.1',
-                           '127.0.0.1'),
+                           '127.0.0.1'),
                      array('127.0.0.1:99',
-                           '127.0.0.1:99'),
+                           '127.0.0.1:99'),
                      array('127.0.0.1/Name:test.php',
-                           '127.0.0.1/Name:test.php'),
+                           '127.0.0.1/Name:test.php'),
                      array('127.0.0.1/~test',
-                           '127.0.0.1/~test'),
+                           '127.0.0.1/~test'),
                      array('127.0.0.1/+test',
-                           '127.0.0.1/+test'),
+                           '127.0.0.1/+test'),
                      array('127.0.0.1/$test',
-                           '127.0.0.1/$test'),
+                           '127.0.0.1/$test'),
                      array('127.0.0.1/\'test',
-                           '127.0.0.1/\'test'),
+                           '127.0.0.1/\'test'),
                      array('127.0.0.1/"test',
-                           '127.0.0.1/"test'),
+                           '127.0.0.1/"test'),
                      array('127.0.0.1/test"test',
-                           '127.0.0.1/test"test'),
+                           '127.0.0.1/test"test'),
                      array('127.0.0.1/-test',
-                           '127.0.0.1/-test'),
+                           '127.0.0.1/-test'),
                      array('127.0.0.1/_test',
-                           '127.0.0.1/_test'),
+                           '127.0.0.1/_test'),
                      array('127.0.0.1/!test',
-                           '127.0.0.1/!test'),
+                           '127.0.0.1/!test'),
                      array('127.0.0.1/*test',
-                           '127.0.0.1/*test'),
+                           '127.0.0.1/*test'),
                      array('127.0.0.1/test%20stuff',
-                           '127.0.0.1/test%20stuff'),
+                           '127.0.0.1/test%20stuff'),
                      array('http://[::1]:99/test.php',
-                           'http://[::1]:99/test.php'),
+                           'http://[::1]:99/test.php'),
                      array('http://::1/test.php',
-                           'http://::1/test.php'),
+                           'http://::1/test.php'),
                      array('http://::1',
-                           'http://::1'),
+                           'http://::1'),
                      array('2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php',
-                           '2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php'),
+                           '2001:4978:1b5:0:21d:e0ff:fe66:59ab/test.php'),
                      array('[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php',
-                           '[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php'),
+                           '[2001:4978:1b5:0:21d:e0ff:fe66:59ab]:99/test.php'),
                      array('2001:4978:1b5:0:21d:e0ff:fe66:59ab',
-                           '2001:4978:1b5:0:21d:e0ff:fe66:59ab'),
+                           '2001:4978:1b5:0:21d:e0ff:fe66:59ab'),
                      array('http://127.0.0.1',
-                           'http://127.0.0.1'),
+                           'http://127.0.0.1'),
                      array('example.com',
-                           'example.com'),
+                           'example.com'),
                      array('example.com',
-                           'example.com'),
+                           'example.com'),
                      array('http://example.com',
-                           'http://example.com'),
+                           'http://example.com'),
                      array('http://example.com.',
-                           'http://example.com.'),
+                           'http://example.com.'),
                      array('/var/lib/example.so',
                            '/var/lib/example.so'),
                      array('example',
                            'example'),
                      array('user@example.com',
-                           'user@example.com'),
+                           'user@example.com'),
                      array('user_name+other@example.com',
-                           'user_name+other@example.com'),
+                           'user_name+other@example.com'),
                      array('mailto:user@example.com',
-                           'mailto:user@example.com'),
+                           'mailto:user@example.com'),
                      array('mailto:user@example.com?subject=test',
-                           'mailto:user@example.com?subject=test'),
+                           'mailto:user@example.com?subject=test'),
                      array('xmpp:user@example.com',
-                           'xmpp:user@example.com'),
+                           'xmpp:user@example.com'),
                      array('#example',
                            '#'),
                      array('#example.com',
@@ -103,167 +103,167 @@ class URLDetectionTest extends PHPUnit_Framework_TestCase
                      array('#.net',
                            '#'),
                      array('http://example',
-                           'http://example'),
+                           'http://example'),
                      array('http://3xampl3',
-                           'http://3xampl3'),
+                           'http://3xampl3'),
                      array('http://example/',
-                           'http://example/'),
+                           'http://example/'),
                      array('http://example/path',
-                           'http://example/path'),
+                           'http://example/path'),
                      array('http://example.com',
-                           'http://example.com'),
+                           'http://example.com'),
                      array('https://example.com',
-                           'https://example.com'),
+                           'https://example.com'),
                      array('ftp://example.com',
-                           'ftp://example.com'),
+                           'ftp://example.com'),
                      array('ftps://example.com',
-                           'ftps://example.com'),
+                           'ftps://example.com'),
                      array('http://user@example.com',
-                           'http://user@example.com'),
+                           'http://user@example.com'),
                      array('http://user:pass@example.com',
-                           'http://user:pass@example.com'),
+                           'http://user:pass@example.com'),
                      array('http://example.com:8080',
-                           'http://example.com:8080'),
+                           'http://example.com:8080'),
                      array('http://example.com:8080/test.php',
-                           'http://example.com:8080/test.php'),
+                           'http://example.com:8080/test.php'),
                      array('example.com:8080/test.php',
-                           'example.com:8080/test.php'),
+                           'example.com:8080/test.php'),
                      array('http://www.example.com',
-                           'http://www.example.com'),
+                           'http://www.example.com'),
                      array('http://example.com/',
-                           'http://example.com/'),
+                           'http://example.com/'),
                      array('http://example.com/path',
-                           'http://example.com/path'),
+                           'http://example.com/path'),
                      array('http://example.com/path.html',
-                           'http://example.com/path.html'),
+                           'http://example.com/path.html'),
                      array('http://example.com/path.html#fragment',
-                           'http://example.com/path.html#fragment'),
+                           'http://example.com/path.html#fragment'),
                      array('http://example.com/path.php?foo=bar&bar=foo',
-                           'http://example.com/path.php?foo=bar&bar=foo'),
+                           'http://example.com/path.php?foo=bar&bar=foo'),
                      array('http://example.com.',
-                           'http://example.com.'),
+                           'http://example.com.'),
                      array('http://müllärör.de',
-                           'http://müllärör.de'),
+                           'http://müllärör.de'),
                      array('http://ﺱﺲﺷ.com',
-                           'http://ﺱﺲﺷ.com'),
+                           'http://ﺱﺲﺷ.com'),
                      array('http://сделаткартинки.com',
-                           'http://сделаткартинки.com'),
+                           'http://сделаткартинки.com'),
                      array('http://tūdaliņ.lv',
-                           'http://tūdaliņ.lv'),
+                           'http://tūdaliņ.lv'),
                      array('http://brændendekærlighed.com',
-                           'http://brændendekærlighed.com'),
+                           'http://brændendekærlighed.com'),
                      array('http://あーるいん.com',
-                           'http://あーるいん.com'),
+                           'http://あーるいん.com'),
                      array('http://예비교사.com',
-                           'http://예비교사.com'),
+                           'http://예비교사.com'),
                      array('http://example.com.',
-                           'http://example.com.'),
+                           'http://example.com.'),
                      array('http://example.com?',
-                           'http://example.com?'),
+                           'http://example.com?'),
                      array('http://example.com!',
-                           'http://example.com!'),
+                           'http://example.com!'),
                      array('http://example.com,',
-                           'http://example.com,'),
+                           'http://example.com,'),
                      array('http://example.com;',
-                           'http://example.com;'),
+                           'http://example.com;'),
                      array('http://example.com:',
-                           'http://example.com:'),
+                           'http://example.com:'),
                      array('\'http://example.com\'',
-                           '\'http://example.com\''),
+                           '\'http://example.com\''),
                      array('"http://example.com"',
-                           '"http://example.com"'),
+                           '"http://example.com"'),
                      array('"http://example.com/"',
-                           '"http://example.com/"'),
+                           '"http://example.com/"'),
                      array('http://example.com',
-                           'http://example.com'),
+                           'http://example.com'),
                      array('(http://example.com)',
-                           '(http://example.com)'),
+                           '(http://example.com)'),
                      array('[http://example.com]',
-                           '[http://example.com]'),
+                           '[http://example.com]'),
                      array('',
-                           '<http://example.com>'),
+                           '<http://example.com>'),
                      array('http://example.com/path/(foo)/bar',
-                           'http://example.com/path/(foo)/bar'),
+                           'http://example.com/path/(foo)/bar'),
                      array('http://example.com/path/[foo]/bar',
-                           'http://example.com/path/[foo]/bar'),
+                           'http://example.com/path/[foo]/bar'),
                      array('http://example.com/path/foo/(bar)',
-                           'http://example.com/path/foo/(bar)'),
+                           'http://example.com/path/foo/(bar)'),
                      //Not a valid url - urls cannot contain unencoded square brackets
                      array('http://example.com/path/foo/[bar]',
-                           'http://example.com/path/foo/[bar]'),
+                           'http://example.com/path/foo/[bar]'),
                      array('Hey, check out my cool site http://example.com okay?',
-                           'Hey, check out my cool site http://example.com okay?'),
+                           'Hey, check out my cool site http://example.com okay?'),
                      array('What about parens (e.g. http://example.com/path/foo/(bar))?',
-                           'What about parens (e.g. http://example.com/path/foo/(bar))?'),
+                           'What about parens (e.g. http://example.com/path/foo/(bar))?'),
                      array('What about parens (e.g. http://example.com/path/foo/(bar)?',
-                           'What about parens (e.g. http://example.com/path/foo/(bar)?'),
+                           'What about parens (e.g. http://example.com/path/foo/(bar)?'),
                      array('What about parens (e.g. http://example.com/path/foo/(bar).)?',
-                           'What about parens (e.g. http://example.com/path/foo/(bar).)?'),
+                           'What about parens (e.g. http://example.com/path/foo/(bar).)?'),
                      //Not a valid url - urls cannot contain unencoded commas
                      array('What about parens (e.g. http://example.com/path/(foo,bar)?',
-                           'What about parens (e.g. http://example.com/path/(foo,bar)?'),
+                           'What about parens (e.g. http://example.com/path/(foo,bar)?'),
                      array('Unbalanced too (e.g. http://example.com/path/((((foo)/bar)?',
-                           'Unbalanced too (e.g. http://example.com/path/((((foo)/bar)?'),
+                           'Unbalanced too (e.g. http://example.com/path/((((foo)/bar)?'),
                      array('Unbalanced too (e.g. http://example.com/path/(foo))))/bar)?',
-                           'Unbalanced too (e.g. http://example.com/path/(foo))))/bar)?'),
+                           'Unbalanced too (e.g. http://example.com/path/(foo))))/bar)?'),
                      array('Unbalanced too (e.g. http://example.com/path/foo/((((bar)?',
-                           'Unbalanced too (e.g. http://example.com/path/foo/((((bar)?'),
+                           'Unbalanced too (e.g. http://example.com/path/foo/((((bar)?'),
                      array('Unbalanced too (e.g. http://example.com/path/foo/(bar))))?',
-                           'Unbalanced too (e.g. http://example.com/path/foo/(bar))))?'),
+                           'Unbalanced too (e.g. http://example.com/path/foo/(bar))))?'),
                      array('example.com',
-                           'example.com'),
+                           'example.com'),
                      array('example.org',
-                           'example.org'),
+                           'example.org'),
                      array('example.co.uk',
-                           'example.co.uk'),
+                           'example.co.uk'),
                      array('www.example.co.uk',
-                           'www.example.co.uk'),
+                           'www.example.co.uk'),
                      array('farm1.images.example.co.uk',
-                           'farm1.images.example.co.uk'),
+                           'farm1.images.example.co.uk'),
                      array('example.museum',
-                           'example.museum'),
+                           'example.museum'),
                      array('example.travel',
-                           'example.travel'),
+                           'example.travel'),
                      array('example.com.',
-                           'example.com.'),
+                           'example.com.'),
                      array('example.com?',
-                           'example.com?'),
+                           'example.com?'),
                      array('example.com!',
-                           'example.com!'),
+                           'example.com!'),
                      array('example.com,',
-                           'example.com,'),
+                           'example.com,'),
                      array('example.com;',
-                           'example.com;'),
+                           'example.com;'),
                      array('example.com:',
-                           'example.com:'),
+                           'example.com:'),
                      array('\'example.com\'',
-                           '\'example.com\''),
+                           '\'example.com\''),
                      array('"example.com"',
-                           '"example.com"'),
+                           '"example.com"'),
                      array('example.com',
-                           'example.com'),
+                           'example.com'),
                      array('(example.com)',
-                           '(example.com)'),
+                           '(example.com)'),
                      array('[example.com]',
-                           '[example.com]'),
+                           '[example.com]'),
                      array('',
-                           '<example.com>'),
+                           '<example.com>'),
                      array('Hey, check out my cool site example.com okay?',
-                           'Hey, check out my cool site example.com okay?'),
+                           'Hey, check out my cool site example.com okay?'),
                      array('Hey, check out my cool site example.com.I made it.',
-                           'Hey, check out my cool site example.com.I made it.'),
+                           'Hey, check out my cool site example.com.I made it.'),
                      array('Hey, check out my cool site example.com.Funny thing...',
-                           'Hey, check out my cool site example.com.Funny thing...'),
+                           'Hey, check out my cool site example.com.Funny thing...'),
                      array('Hey, check out my cool site example.com.You will love it.',
-                           'Hey, check out my cool site example.com.You will love it.'),
+                           'Hey, check out my cool site example.com.You will love it.'),
                      array('What about parens (e.g. example.com/path/foo/(bar))?',
-                           'What about parens (e.g. example.com/path/foo/(bar))?'),
+                           'What about parens (e.g. example.com/path/foo/(bar))?'),
                      array('What about parens (e.g. example.com/path/foo/(bar)?',
-                           'What about parens (e.g. example.com/path/foo/(bar)?'),
+                           'What about parens (e.g. example.com/path/foo/(bar)?'),
                      array('What about parens (e.g. example.com/path/foo/(bar).)?',
-                           'What about parens (e.g. example.com/path/foo/(bar).)?'),
+                           'What about parens (e.g. example.com/path/foo/(bar).)?'),
                      array('What about parens (e.g. example.com/path/(foo,bar)?',
-                           'What about parens (e.g. example.com/path/(foo,bar)?'),
+                           'What about parens (e.g. example.com/path/(foo,bar)?'),
                      array('file.ext',
                            'file.ext'),
                      array('file.html',