The script works fine but I have a question with the following line:
$Pattern=(http://)([^[:space:]]+) ([[:alnum:]\.,-?/=]); // The
variable
$Pattern is declared with three groupings.
My question:
If the user inadvertantly inputs a *space* _after_ the http://
grouping
and
_before_ the
John W. Holmes:
Yes, that's correct. That piece of the pattern matches anything that's
not a space, one or more times.
I tried the script by putting a space before the URL and the PHP still
processes the data with no error.
A space before everything is fine, as the pattern will match the
For instance, let's say I put _absolutely nothing_ in the URL textbox
and
then hit submit - the PHP still processes _without_ an error.
It says:
Your submission -- -- has been received!
I would've thought the eregi_replace() function would've validated an
entry
with no characters.
Well, whether it causes an error not depends on your code. That's just
the pattern you showed. It may not match anything, so nothing gets
replaced with eregi_replace() and hence no active link is created, but
it may not necessarily cause an error.
Can you show me some of the code in context,
$Pattern = (http://)?([^[:space:]]+)([[:alnum:]\.,-_?/=]);
$Replace = a href=\http://\\2\\3\; target=\_new\\\2\\3/a;
$Array[URL] = eregi_replace($Pattern, $Replace, $Array[URL]);
print (Your submission--$Array[URL]--has been received!BR\n);
That does no checking or validation at all. It
Holmes:
That's just the pattern you showed. It may not match anything, so nothing
gets
replaced with eregi_replace() and hence no active link is created, but
it may not necessarily cause an error.
.
Right.
The pattern does not match anything in the input string of
6 matches
Mail list logo