Click to See Complete Forum and Search --> : perl script works but would like a tweak


mikegordon
08-21-2003, 01:34 AM
This perl script works but would like a tweak so that it will catch starting with one, a single, bad word.
In uther woids, how can I get the **** thing to work so that if'n badwurds > -1 it will trigger the that's a no-no return page?
\IO've tried every form of writing the line sodat even a single illegal wurd triggers the you bad boy page, but ass izz, it takes 2 to tango.
mike

if($blockbadwords == 1) {

Jeff Mott
08-21-2003, 12:15 PM
This perl script...Sorry, the mental telepathy fails me. Just what does this script refer to? We can't tweak what we don't have.

mikegordon
08-21-2003, 01:23 PM
Originally posted by Jeff Mott
Sorry, the mental telepathy fails me. Just what does this script refer to? We can't tweak what we don't have.

Thx for your resppnse, Jeff.
Since the script works< my thought was that since all I needed to be tweaked is the line:

if($blockbadwords == 1) {

so as to avoid sending so much stuffe'

The perl script in which the line below apprears works for me but I would like a tweak so that it will catch starting with one, a single, bad word.

if($blockbadwords == 1) {

In uther woids, how can I get the if statement to work so that if there is only one badwords it will trigger the that's a no-no return page?
I've tried every form of writing the line so that even a single illegal word triggers the error page, but as izz, it takes 2 words to trigger the page,
thx,
mike

Jeff Mott
08-21-2003, 02:17 PM
I have no idea how the variable $blockbadwords is set, and thus have no idea what it should be checked for. Otherwise all I can give is some mindless guesses.

$blockbadwords > 0
$blockbadwords > -1

mikegordon
08-21-2003, 06:17 PM
Thx for responding again, Jeff.
I had to shut down to install a cable modem and didn't realize reply I had prepared had not been sent.
if($blockbadwords == 1) {
this line in the perl script below will not trigger the illegal word error page untill it find 2 words on the list, but I would like a tweak so that it will catch starting with a single, bad word.
(I'd love to be able to ban eMail addresses and URLs too, this won't catch anything in those string, as well as for it tobe case insensitive.

#!/usr/bin/perl

$htdocs = "/usr/local/etc/httpd/htdocs";
$url = "http://www.dcdancenet.com";

$datadir = "/usr/local/etc/httpd/cgi-bin/filter";
$blockbadwords = 1;

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

# Split the name-value pairs
@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);

$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<([^>]|\n)*>//g;
$value =~ s/<//g;
$value =~ s/>//g;
$FORM{$name} = $value;
}


# Check for bad words
if($blockbadwords == 1) {
open(BADWORDS, "$datadir/badwords.txt") || &showerror("opening bad word list.");
@badentries = <BADWORDS>;
close(BADWORDS);

foreach $word(@badentries) {
chop($word);

if ($FORM{'name'} =~ m/$word(\.| |\!|\,|\?|\-)/ig) {
&bad_word_used($word);
}
if ($FORM{'title'} =~ m/$word(\.| |\!|\,|\?|\-)/ig) {
&bad_word_used($word);
}
if ($FORM{'description'} =~ m/$word(\.| |\,|\!|\?|\-)/ig) {
&bad_word_used($word);
}
if ($FORM{'street'} =~ m/$word(\.| |\!|\,|\?|\-)/ig) {
&bad_word_used($word);
}
if ($FORM{'city'} =~ m/$word(\.| |\!|\,|\?|\-)/ig) {
&bad_word_used($word);
}
if ($FORM{'state'} =~ m/$word(\.| |\!|\,|\?|\-)/ig) {
&bad_word_used($word);
}
if ($FORM{'email'} =~ m/$word(\.| |\!|\,|\?|\-)/ig) {
&bad_word_used($word);
}
if ($FORM{'eMail'} =~ m/$word(\.| |\!|\,|\?|\-)/ig) {
&bad_word_used($word);
}
if ($FORM{'url'} =~ m/$word(\.| |\!|\,|\?|\-)/ig) {
&bad_word_used($word);
}
if ($FORM{'phone'} =~ m/$word(\.| |\!|\,|\?|\-)/ig) {
&bad_word_used($word);
}
}
}
there is a subroutine for the error page, after all the other actions performed by this script. Do you need it also?

thx,
mike

Jeff Mott
08-21-2003, 06:31 PM
From what I can see it will take you to an error page after detecting at least one bad word. But the catch is any bad word must be followed by a period, space, exclamation point, comma, question mark, or hyphen.

mikegordon
08-21-2003, 08:11 PM
Originally posted by Jeff Mott
From what I can see it will take you to an error page after detecting at least one bad word. But the catch is any bad word must be followed by a period, space, exclamation point, comma, question mark, or hyphen.

tunz out that, after testing everything I could think of that it takes AT LEAST two bad words.
one bad word and a space and any non badword slips thru.

So, I'm hoping that there could be a way to write the directive to if there is even just one badword to trigger the err page.

I've seen a similar script with > -1 but could not get it to work in this one.
(The other one REPLACES the bad word with **** which is not acceptable)

Why would this script be so picky?

Jeff Mott
08-21-2003, 11:27 PM
The other one REPLACES the bad word with **** which is not acceptableWell then what is acceptable?Why would this script be so picky?Everything in that part of the script you posted is poor programming. Maybe try this instead (note that for this example "badwords.txt" must be in the same directory as the script).#!/usr/bin/perl -wT

my %config = (
BlockBadWords => TRUE,
BadWordErrorPage => 'http://www.some-place.com/path/badword.html',
);

use strict;
use warnings FATAL => 'all';
use CGI;
use Fcntl qw[:flock];

use constant TRUE => 1;
use constant FALSE => 0;

my $cgi = CGI->new();

if ($config{BlockBadWords}) {
open(BWORD, 'badwords.txt') or die $!;
flock(BWORD, LOCK_SH) or die $!;
BADWORD: while (my $bword = <BWORD>) {
chomp($bword);
for ($cgi->param()) {
if ($cgi->param($_) =~ /\b$bword\b/i) {
print($cgi->redirect($config{BadWordErrorPage})) or die $!;
last BADWORD;
}
}
}
close(BWORD) or die $!;
}

mikegordon
08-21-2003, 11:46 PM
[QUOTE]
The other one REPLACES the bad word with **** which is not acceptable
--------------------------------------------------------------------------------

Well then what is acceptable
_____________________________________-

An error page.

mikegordon
08-22-2003, 01:36 AM
quote:
--------------------------------------------------------------------------------
Everything in that part of the script you posted is poor programming. Maybe try this instead ...

Wellsir. The thing is that the script worked. poor programming and all, as long as the user typed 2 or more illegal words.
So I tried your code and after quite some time I got the script working again, that is, I got it to post the form contents, bad words and all.
Your code didn't catch any bad words, I know, I know, it won't work well with poor progamming.
But, again, the thing is that it does work, except for that little bit of code which I tried to say was all that needed changing.

Is it possible to just deal with the code as is, and edit the line that controls the nunber of bad workds needed (1) to trigger the sub routine that will print an error page?

Here's the code: #!/usr/bin/perl

$htdocs = "/usr/local/etc/httpd/htdocs";
$url = "http://www.dcdancenet.com";

$datadir = "/usr/local/etc/httpd/cgi-bin/filter";
$blockbadwords = 1;

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

# Split the name-value pairs
@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);

$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<([^>]|\n)*>//g;
$value =~ s/<//g;
$value =~ s/>//g;
$FORM{$name} = $value;
}


# Check for bad words
if($blockbadwords == 1) {
open(BADWORDS, "$datadir/badwords.txt") || &showerror("opening bad word list.");
@badentries = <BADWORDS>;
close(BADWORDS);

foreach $word(@badentries) {
chop($word);

if ($FORM{'name'} =~ m/$word(\.| |\!|\,|\?|\-)/ig) {
&bad_word_used($word);
}
if ($FORM{'title'} =~ m/$word(\.| |\!|\,|\?|\-)/ig) {
&bad_word_used($word);
}
if ($FORM{'description'} =~ m/$word(\.| |\,|\!|\?|\-)/ig) {
&bad_word_used($word);
}
if ($FORM{'street'} =~ m/$word(\.| |\!|\,|\?|\-)/ig) {
&bad_word_used($word);
}
if ($FORM{'city'} =~ m/$word(\.| |\!|\,|\?|\-)/ig) {
&bad_word_used($word);
}
if ($FORM{'state'} =~ m/$word(\.| |\!|\,|\?|\-)/ig) {
&bad_word_used($word);
}
if ($FORM{'email'} =~ m/$word(\.| |\!|\,|\?|\-)/ig) {
&bad_word_used($word);
}
if ($FORM{'eMail'} =~ m/$word(\.| |\!|\,|\?|\-)/ig) {
&bad_word_used($word);
}
if ($FORM{'url'} =~ m/$word(\.| |\!|\,|\?|\-)/ig) {
&bad_word_used($word);
}
if ($FORM{'phone'} =~ m/$word(\.| |\!|\,|\?|\-)/ig) {
&bad_word_used($word);
}
}
}

Jeff Mott
08-22-2003, 02:21 AM
Your code didn't catch any bad wordsYou must have not integrated it into your program correctly. I tested it before I posted it, and just retested it again to be sure. It does work.... and edit the line that controls the nunber of bad workds needed (1)There is no such control for number of bad words needed. The "1" you refer to is a configuration option, just as the BlockBadWords => TRUE line in the code I posted. There is nothing in the code you posted that requires two bad words to appear.

mikegordon
08-22-2003, 09:25 AM
Originally posted by Jeff Mott
[B]You must have not integrated it into your program correctly. I tested it before I posted it, and just retested it again to be sure.
aI figured you'd say it ways me and not your code.
You see, the thing is your code does not intergrate in my script. That's why I was asking for a minimalist tweak, so that there would not be this huge effort to re-write the whole thing because it already worked OK, I just wanted one little tweak to make it work better.

quote:
--------------------------------------------------------------------------------
... and edit the line that controls the number of bad works needed (1)
--------------------------------------------------------------------------------

There is no such control for number of bad words needed. The "1" you refer to is a configuration option, just as the BlockBadWords => TRUE line in the code I posted. There is nothing in the code you posted that requires two bad words to appear
__________________________________


OK, so it's a config option, geeeeez. Never the less, while it may be as you claim that there is no requirement for two bad words, I think that if you really look closely, you can see from the script I included last msg. that only one bad word will not trigger the err msg.

Jeff Mott
08-22-2003, 09:47 AM
I think that if you really look closely, you can see from the script I included last msg. that only one bad word will not trigger the err msgLooking closely at the script you posted is what brought me to the conclusion that only one bad word is needed. But if you don't believe then feel free to run this little example at the command line:@badentries = qw[bad];
$FORM{state} = 'bad.';

foreach $word(@badentries) {
if ( $FORM{'name'} =~ m/$word(\.| |\!|\,|\?|\-)/ig ) {
&bad_word_used($word);
}
if ( $FORM{'title'} =~ m/$word(\.| |\!|\,|\?|\-)/ig ) {
&bad_word_used($word);
}

if ( $FORM{'description'} =~ m/$word(\.| |\,|\!|\?|\-)/ig ) {
&bad_word_used($word);
}
if ( $FORM{'street'} =~ m/$word(\.| |\!|\,|\?|\-)/ig ) {
&bad_word_used($word);
}

if ( $FORM{'city'} =~ m/$word(\.| |\!|\,|\?|\-)/ig ) {
&bad_word_used($word);
}
if ( $FORM{'state'} =~ m/$word(\.| |\!|\,|\?|\-)/ig ) {
&bad_word_used($word);
}

if ( $FORM{'email'} =~ m/$word(\.| |\!|\,|\?|\-)/ig ) {
&bad_word_used($word);
}
if ( $FORM{'eMail'} =~ m/$word(\.| |\!|\,|\?|\-)/ig ) {
&bad_word_used($word);
}

if ( $FORM{'url'} =~ m/$word(\.| |\!|\,|\?|\-)/ig ) {
&bad_word_used($word);
}
if ( $FORM{'phone'} =~ m/$word(\.| |\!|\,|\?|\-)/ig ) {
&bad_word_used($word);
}
}

sub bad_word_used { print 'bad word' }In this example there is only one word in all of %FORM, and it just happens to be a bad one. And as expected this will print "bad word".

mikegordon
08-22-2003, 11:12 AM
OK...
Let me re-state:
As my script now exists, there must be more than one bad word in a field to trigger the err msg. The script looks in each field for bad words and will call the err msg sub routine only if finds more than one word that match the words in the bad words txt file.
It is not a cumulative search (each field is tested separately). it would be my hope that the script could be tweaked to call the sub routine when only a single bad word is found in a field.

If the script found any bad word anywhere in the form data string and called the err msg, that would be fine.
Just seems the easiest way to tweak the script is to leave it alone as much as possible and just edit the line that has the ==1 in it to something else so that it will call the err msg on encountering a single bad word.

I'm sure your script works fine, for you. I don't see how this latest version below checks the badword.txt file, for instance, so in this case, UR right, I don't see how to integrate this last bit of code into my script.

I'm impressed with all your effort and wonder how to avoid wasting it on re-inventing this particual wheel??
thx,
mike

Originally posted by mikegordon
... your code does not intergrate in my script. That's why I was asking for a minimalist tweak, so that there would not be this huge effort to re-write the whole thing because it already worked OK, I just wanted one little tweak to make it work better.

quote:
--------------------------------------------------------------------------------
... and edit the line that controls the number of bad works needed (1)
--------------------------------------------------------------------------------

There is no such control for number of bad words needed. The "1" you refer to is a configuration option, just as the BlockBadWords => TRUE line in the code I posted. There is nothing in the code you posted that requires two bad words to appear
__________________________________


OK, so it's a config option, geeeeez. Never the less, while it may be as you claim that there is no requirement for two bad words, I think that if you really look closely, you can see from the script I included last msg. that only one bad word will not trigger the err msg.

Jeff Mott
08-22-2003, 03:01 PM
As my script now exists, there must be more than one bad word in a field to trigger the err msgOf the code that you posted, the error message will be triggered with at least one bad word; not more than one. That isn't going to change no matter how much you redescribe the problem.

Do you have a site up with the program running and the full source available?...and just edit the line that has the ==1Sigh... you did read my previous posts? Editing that line will not do what you want. When $blockbadwords is set, it is a yes or no question. e.g.,

# block bad words? yes
$blockbadwords = 1;

- or -

# block bad words? no
$blockbadwords = 0;

Then later in the program...

# if chose yes for blocking bad words
if ($blockbadwords == 1)

mikegordon
08-22-2003, 03:13 PM
Sorry, the reply submitted before I finished.
UKIN rest at http:dcdancenet.com/addlinks/
prefer that you select one of the less popular links pages, such as the Flamenco

mikegordon
08-22-2003, 03:51 PM
Quote:
"When $blockbadwords is set, it is a yes or no question. e.g.,

# block bad words? yes
$blockbadwords = 1;

- or -

# block bad words? no
$blockbadwords = 0;

Then later in the program...

# if chose yes for blocking bad words
if ($blockbadwords == 1) [/B][/QUOTE]

OK!
Now what you say makes sense.
After you have tested my form at http://dcdancenet.com/addlinks/
(bad words text file for convenient reference at: badwords.txt.
After you have disovered that it takes MORE THAN ONE BAD WORD to have the error msg apperar on screen, where would you edit the code so that it only takes one word tocall the err page?
thx
mike

Jeff Mott
08-22-2003, 07:18 PM
(bad words text file for convenient reference at: badwords.txtI do need more than the filename you know. There is still the path to that file I need. Luckily I was able to guess http://dcdancenet.com/cgi-bin/filter/badwords.txt. Unluckily, the file permissions deny me access. I also still cannot see the entire source of the program. Otherwise all I have to work with is the code you posted, which I've told you repeatedly is triggered with only one bad word. I even posted an example illustrating that point a little ways back. Maybe the full programs works a little differently and maybe it doesn't. But I can't tell without being able to see the code for it.

mikegordon
08-23-2003, 12:57 AM
Originally posted by Jeff Mott
I do need more than the filename you know. There is still the path to that file I need. Luckily I was able to guess http://dcdancenet.com/cgi-bin/filter/badwords.txt. Unluckily, the file permissions deny me access. I also still cannot see the entire source of the program. Otherwise all I have to work with is the code you posted, which I've told you repeatedly is triggered with only one bad word. I even posted an example illustrating that point a little ways back. Maybe the full programs works a little differently and maybe it doesn't. But I can't tell without being able to see the code for it.

You know, i really want to focus on the code that I posted. __IF__ you were to try posting only one bad word on the form you would finally see that it takes more than one word to call the error page.
It is odd that you refuse to accept the simple statement of fact that it takes more than one word to get the code to call the err. msg.
The form and script function just fine without the code bit added to catch badwords, and when the code I posted is inserted, it continues to function properly with the exception of requiring more that one badword to call the err msg.
This fact will not change until something is changed in the code I posted.
I really want to focus on the badword code. I sent the link for the badword list text http://dcdancenet.com/addlinks/badword.txt for you to try combinations so that you can see for youself that it takes more than one badword to cal the err. msg page. I really want to focus just on the badword code.
Thanks for your help.
mike

Jeff Mott
08-23-2003, 09:50 AM
I sent the link for the badword list text http://dcdancenet.com/addlinks/badword.txtThat link gives me a 404 not found error.It is odd that you refuse to accept the simple statement of fact that it takes more than one word to get the code to call the err. msg.Since it is still possible that something in the rest of the program does some action to change the way it works, you'll note in all my posts I am referring to the code you posted. There is a very simple reason why I consistently say that it only needs one word: I ran the code, and, sure enough, it was triggered after one bad word. That's not interpretation or opinion, that's just what the code does. Still, like I said (again), something else in the program may be causing your problem (maybe something in &bad_word_used()). So I will (again) ask you to see the source of the program.

Note that I am getting very tired of repeating myself. If you continue to disbelieve everything I say then there is nothing more I can do to help you.

mikegordon
08-23-2003, 11:41 AM
Originally posted by Jeff Mott
That link gives me a 404 not found error.

Sorry try it now. http://dcdancenet.com/addlinks/badword.txt

The code for the badword was written (not by me) to be portable, insertablw wherever. It does not trigger with only one word.
I'm hoping you will try it on my form so you will see that.
Since I do not know the set up when you ran the code I'm just happy it ran for you.
I think you do not believe me when I say that it takes more that one bad word, so I'm hoping to find a way to get you to try it on my form.
I think it has to do with the chop statement.
Take a look using the bad words txt link.
thx
mike
--------------------------------------------------

\Since it is still possible that something in the rest of the program does some action to change the way it works, you'll note in all my posts I am referring to the code you posted. There is a very simple reason why I consistently say that it only needs one word: I ran the code, and, sure enough, it was triggered after one bad word. That's not interpretation or opinion, that's just what the code does. Still, like I said (again), something else in the program may be causing your problem (maybe something in &bad_word_used()). .

Jeff Mott
08-23-2003, 11:54 AM
Sorry try it now. http://dcdancenet.com/addlinks/badword.txtStill the same.

Jeff Mott
08-23-2003, 01:08 PM
I have it now: http://dcdancenet.com/addlinks/badwords.txt

Just want to confirm this as the error message for posting a bad word.That Data included text that is not dance related and is not permitted!
Please, don't post bogus work at home schemes fraudulent job opportunities, or other scams, or text concerning the enhancement of various body parts, any of an impressive assortment of drugs, self improvement schemes, sexual perfomance aids, and or any other non dance-related items.I was sent to this page by using one bad word.

mikegordon
08-23-2003, 07:37 PM
Originally posted by Jeff Mott
I have it now: http://dcdancenet.com/addlinks/badwords.txt

Just want to confirm this as the error message for posting a bad word.I was sent to this page by using one bad word.
_______________
reply:
YES!
EXCELLENT!
Now, I know I'm trying your patience, but wouldst thou tell me what the "bad word" is and whether there was more than one occurance of the word?
thx!
mike

Jeff Mott
08-23-2003, 08:06 PM
but wouldst thou tell me what the "bad word" isAnything out of badwords.txt. I tested several.and whether there was more than one occurance of the word?As I've already said in my post just before this one, there was only one occurance.

What text are you trying that is not working for you?

mikegordon
08-23-2003, 08:17 PM
quote:
--------------------------------------------------------------------------------
Originally posted by Jeff Mott
I have it now: http://dcdancenet.com/addlinks/badwords.txt

Just want to confirm this as the error message for posting a bad word.I was sent to this page by using one bad word.


Originally posted by mikegordon
_______________
reply:
YES!
EXCELLENT!
Now, I know I'm trying your patience, but wouldst thou tell me what the "bad word" is and whether there was more than one occurance of the word?
thx!
mike

ooooooooooooops!
I typed in the word supplement, (it's on the badword.txt file) and it posted. UKIN see it at: http://www.dcdancenet.com/moredancing/flamenco.shtml

So, I'm puzzled when you write "I was sent to this page by using one bad word".

???
thx,
mike

Jeff Mott
08-23-2003, 08:43 PM
Ahh, I see. You apparently did not read one of my earlier posts.Originally posted by Jeff Mott
From what I can see it will take you to an error page after detecting at least one bad word. But the catch is any bad word must be followed by a period, space, exclamation point, comma, question mark, or hyphen.

mikegordon
08-23-2003, 09:42 PM
Originally posted by Jeff Mott
Ahh, I see. You apparently did not read one of my earlier posts.

ummmmmmmmm, well, being certain about what someone has not read can be a riskly business.
I remember your comment above and distinctly remember typing in the word work plus a space and that it did post.

You can see the result of that when I did it again, moments ago on the flamenco page.

So, we see that the post or err msg is inconsistent. Seems to me that the approach is to config the script to call the subroutine on matching > -1 or whatever syntax will activate the err msg when a word on the list is matched as requiring that there be a space or whatever will prevent matching a badword in the urls and eMail.

mikegordon
08-23-2003, 09:48 PM
Whooooooops!
Hold on, it's the word workers that's in the badword list.
Sorry for that part of my reply--

Still it seems to me that the approach is to config the script to call the subroutine on matching > -1 or whatever syntax will activate the err msg when a word on the list is matched -incase- they get cute try a word with a space, etc.

AND, as requiring that there be a space or whatever will prevent matching a badword in the urls and eMail.

Jeff Mott
08-23-2003, 10:25 PM
I tried "workers" followed by a space, and then tried it again followed by a period. Both triggered the error.

Are you sure your tests include a space? I posted worker (picked so it would not be blocked) followed by a space. On the page you can see the difference when a space is there and when it is not. Your test posts for workers do not have a space with them.Still it seems to me that the approach is to config the script to call the subroutine...activate the err msg when a word on the list is matchedThis is what the script does now. There really is nothing to config. Unless you want to change something else now.

mikegordon
08-23-2003, 11:32 PM
Originally posted by Jeff Mott
I tried "workers" followed by a space, and then tried it again followed by a period. Both triggered the error.

Are you sure your tests include a space? I posted worker (picked so it would not be blocked) followed by a space. On the page you can see the difference when a space is there and when it is not. Your test posts for workers do not have a space with them.This is what the script does now. There really is nothing to config. Unless you want to change something else now.

Yes, Yes Yes.
My first sentence says that the space and the period trigger the error.

The additional comment address the fact that needing a spac or a period is not what is wanted.
What is wanted is for the code to catch the bad word if it is the only word, and does not have a period or a space, as well as a way to catch the badword when it is part of the url or the eMail address, where it does not have a period or a space and in fact is.

Jeff Mott
08-24-2003, 12:31 AM
Yes, Yes Yes.
My first sentence says that the space and the period trigger the error.After rereading your last post, I find no sentence that says that.

But anyway, replace all instances of

m/$word(\.| |\!|\,|\?|\-)/ig

with

/\b$word\b/i

mikegordon
08-24-2003, 10:08 AM
Originally posted by Jeff Mott
"I tried "workers" followed by a space, and then tried it again followed by a period. Both triggered the error. "

Originally posted by Jeff Mott
"After rereading your last post, I find no sentence that says that." (the above text)

But anyway, replace all instances of

m/$word(\.| |\!|\,|\?|\-)/ig

with

/\b$word\b/i

OK!
Sorry, I see that I did not include that sentence as I intended, essentially to echo your comment that I also found that adding the space or period would trigger the err as you did.

Thanks for creating the new code!

Thanks for pointing out that the ==1 turned on the code, not determining the quantity of badwords.

I did not expect to be able to find the puncuation requirements in the code, so that as I see, now, in replacing the old with yours that the punctuation is indeed part of the matching code, and I understand why it was written that way.

I am grateful for your code as I would not have know what to write to replace the code.

I've edited my script and tested it, finding that it does work as expected. THANKS!
It will catch some words that are part of anothere word or term that would be OK, but catching the eMail and url with the bad word is important.

I will try mixing the code bits, what's your comment on whether it will work with your code on just the eMail and url fields and thee old code on the other fields?

Thanks for your persistence!
mike