Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Simple (for some) Code change

Posted on 2003-03-29
3
Medium Priority
?
175 Views
Last Modified: 2010-03-05
Help please.

The code below reads from the file badurl.txt ie: http://www.test.com and refers to sub routine &no_url

I need the code to do the same but also refer to &no_url when anything occurs after the example http://www.test.com such as http://www.test.com/ or http://www.test.com anything here

# Check for BANNED urls.

open (BANURL, "$basedir/badurl.txt");
@badurl = <BANURL>;
close (BANURL);
     foreach (@badurl) {
     chomp $_;
     $temp = $_;
     $FORM{'url'} =~ tr/A-Z/a-z/;
          if ($FORM{'url'}eq $temp) {
          &no_url;    
     }
}
0
Comment
Question by:malkie
3 Comments
 
LVL 11

Accepted Solution

by:
bcladd earned 400 total points
ID: 8230351
So, if I understand your question, you are asking to call no_url for any value in $FORM{'url'} that has a bad url as a prefix? Use regular expressions:

  if ($FORM{'url'} =~ /^$temp/) {
    &no_url;
  }

The ^ anchors the check at the beginning of the string so you might want to clean out leading spaces in the form before running this test.

Hope this helps, -bcl
0
 
LVL 48

Expert Comment

by:Tintin
ID: 8231966
open BANURL, "$basedir/badurl.txt" or die "Can not open $basedir/badurl.txt $!\n";

while (<BANURL>) {
  chomp;
  no_url() if (/^$FORM{'url'}/i);
}

close BANURL;
0
 

Author Comment

by:malkie
ID: 8233510
Works great
God Bless
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question