Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: How to get post parameters and print/log them in Perl

by marto (Cardinal)
on Nov 11, 2016 at 15:04 UTC ( [id://1175748]=note: print w/replies, xml ) Need Help??


in reply to Re: How to get post parameters and print/log them in Perl
in thread How to get post parameters and print/log them in Perl

What if $var1 contains something like this: my $var1 = "\\'; cat /etc/passwd";? I'm unsure why you'd want to use sed rather than perl to write some data to a file.

Replies are listed 'Best First'.
Re^3: How to get post parameters and print/log them in Perl
by Linicks (Scribe) on Nov 11, 2016 at 15:36 UTC

    Well, it depends on the context - for *known* data input, I would rather use existing tools than re-invent the wheel.

    In the example you gave, surely some sort of user input sanitisation goes on first?

    Nick

      "for *known* data input, I would rather use existing tools than re-invent the wheel.

      As touched on in Passing a regex from a CGI HTML form security is an issue. Here you replied to someone who is obviously struggling with the basics and provided them a foot gun... 'I use this on a couple of my CGI scripts', mentioning nothing about sanitizing the data. Since you're already using perl I see no reason why you don't just write to a file from your script rather than shelling out, running sed with no error checking. Rather than reinvent the wheel this is like taking a unicycle along with you when riding your bike. Sure you could do it, but what's the point? Seems unnecessarily messy.

        As I said, it depends on the context (i.e. HTML form drop down boxes etc.). Also, even if you did just use perl to write to file, you still need to sanitise the data first anyway, no?

        So whatever method is used, all user input data needs to be sanitised before using it - I thought that was a foregone conclusion.

        I once made a unicycle and taught myself to ride it :)

        Nick

        EDIT: Also, I just answered the question and showed one way to do it - I didn't think I needed to provide a full synopsis of how to do the whole lot!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1175748]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 20:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found