Forum Moderators: coopster
if(!eregi("<¦>"))
if (eregi("\]¦\[¦\{¦\}",$dir_txt_main) )
What's happening here?
I just realized that without willing to do it I used an unfinished regex (the top one ) that does the job :) and does not call the string
if(!eregi("<¦>"))
I would like understanding what's going on.
The reason for this is that it is far less likely that an error will remain unnoticed if you specifically *allow* only certain characters. If you forget something while doing this, the consequences are far less likely to create a security vulnerability or go unnoticed.
In other words, start with accepting only "[\w\-]" and add to that if necessary.
Jim
Specially disallowed {} [] and ¦(pipe) and #,*,^, ~
jdMorgan makes lot of sense even if it would be easier (at least to me!) to simply disallow {} [] and ¦(pipe) and #,*,^, ~
I was not able to built it as it is supposed to be.
Thanks
$string = 'This is a good string, including these chars, <>@/,. ;+-=:$%!?';
//$string = 'This is a bad string, including these chars, {}[]¦#*^~';
$allowedChars = preg_quote [php.net]('<>@/,. ;+-=:$%!?', '/');
if (preg_match [php.net]("/[^A-Za-z0-9$allowedChars]/", $string)) {
print 'string is NOT OK!';
} else {
print 'string is OK!';
}