You are here: Re: Extract any URL from any string? « PHP Programming Language « IT news, forums, messages
Re: Extract any URL from any string?

Posted by Janwillem Borleffs on 02/10/07 22:38

deko wrote:
> geturl.php
>
> Too much code to paste here, but have a look at
> http://www.liarsscourge.com/
> So far, I have not found a string that can break this...
>
> Any built-in functions or suggestions for improvement?
>

1. Increase the error_reporting level and you will find some sloppy notices
2. Have a look at parse_url(), which might be useful
3. Use preg_* functions instead of POSIX ereg* function (performance)
4. Strings like the following cause infinite loops:

getURL('fofo http://discovery.co.uk/../foo');

Probable fix:

= Replace:

if (!eregi("^(com|net|org...)$", $urlString_a[$i])) {
...
}

= With:

if (preg_match("!^(com|net|org...)[^$]!", $urlString_a[$i], $m)) {
$urlString_a[$i] = $m[1];
}


JW

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация