Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl print "Content-type:text/html\n\n"; $FORM{'fulltxtpath'} = stripmeta("../www$ENV{'QUERY_STRING'}"); read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @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; $FORM{$name} = $value; } foreach $key (keys(%FORM)) { if ($key =~ /required/i) {if ( ($FORM{$key} eq "") && ($FORM{$key} == +"") ) {failure();}} } open INF, $FORM{'fulltxtpath'} or dienice("Cant open $FORM{'fulltxtpat +h'}"); seek(INF,0,0); @fary = <INF>; close (INF); foreach $key (keys(%FORM)) { $rep = $FORM{$key}; foreach $i (@fary) {$i =~ s/\[$key\]/$rep/g;} } $mailprog = '/usr/lib/sendmail'; open (MAIL, "|$mailprog -t") or dienice("Can't access $mailprog!\n"); foreach $i (@fary) { print MAIL "$i"; } close (MAIL); $FORM{'success'} =~ s/https\:\/\/www.mydomain.com/..\/www/g; open INF, $FORM{'success'} or dienice("Cant open $FORM{'success'}"); seek(INF,0,0); @succtxt = <INF>; close (INF); foreach $i (@succtxt) { print "$i"; } exit; sub stripmeta { my($var1) = @_; @meta = ('&',';','`','\'','\\', '"','|','*','?','~','<','>', '^','(',')','[',']','{','}','$'); $var1 =~ s/\n/ /g; $var1 =~ s/\r/ /g; foreach $met (@meta){ $var1 =~ s/\Q$met\E/ /g; } return $var1 } sub failure { $FORM{'failure'} =~ s/https\:\/\/www.mydomain.com/..\/www/g; open INF, $FORM{'failure'} or dienice("Cant open $FORM{'failure'}"); seek(INF,0,0); @failtxt = <INF>; close (INF); foreach $i (@failtxt) { print "$i"; } exit; } sub dienice { my($errmsg) = @_; my($webmaster) = 'webmaster@mydomain.com'; print <<Eof; <html><head><title>Error!!</title></head><body>The error was $errmsg</ +body></html> Eof exit; }
Will me stripmeta sub protect me from attacks like ;/ rm -r*;/ in the 'QUERY_STRING'??

In reply to Is this safe?? by SilverB1rd

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-03-28 10:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found