<div class="gmail_quote">On Fri, Jan 22, 2010 at 4:55 PM, Dan Linder <span dir="ltr">&lt;<a href="mailto:dan@linder.org">dan@linder.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I&#39;m working on my inherited project trying to fix the various &quot;search&quot;<br>
fields that have been added over the years.  Some fields perform a<br>
strict search for the text, others do the search but ignore case, some<br>
allow basic ^$ regexp modifiers, others treat them as the characters<br>
themselves.   *sigh*<br>
<br>
Since the search string being supplied is coming straight from a text<br>
field on a web page, I don&#39;t think I should use that text directly<br>
inside a regexp query like this, should I:<br>
<br>
    $mycgi = CGI-&gt;new();<br>
    $search_string = $mycgi-&gt;param(&#39;SEARCHSTRING);<br>
    if ($data =~ /$search_string/io) {<br>
        # Do something if we match...<br>
    }<br>
<br>
My understanding is that it is/might be possible to get bad data<br>
pushed into the $search_string and cause the /regexp/ call execute it<br>
or perform something not intended.  But if I<br>
<br>
Or am I/we being overly cautious?  I&#39;ve tried stuffing a number of bad<br>
things into the field and they don&#39;t seem to have any bad effect.<br></blockquote><div><br></div><div>You are definitely not being overcautious. Try searching for: </div><div><br></div><div>(?{open FH,&quot;/etc/passwd&quot;;local $/;print &lt;FH&gt;})</div>
<div><br></div><div>I&#39;d recommend running anything through quotemeta() before using it in your regexp.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<br>
Thanks,<br>
Dan<br>
<br>
--<br>
***************** ************* *********** ******* ***** *** **<br>
&quot;Quis custodiet ipsos custodes?&quot;<br>
    (Who can watch the watchmen?)<br>
    -- from the Satires of Juvenal<br>
&quot;I do not fear computers, I fear the lack of them.&quot;<br>
    -- Isaac Asimov (Author)<br>
** *** ***** ******* *********** ************* *****************<br>
_______________________________________________<br>
Omaha-pm mailing list<br>
<a href="mailto:Omaha-pm@pm.org">Omaha-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/omaha-pm" target="_blank">http://mail.pm.org/mailman/listinfo/omaha-pm</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Andrew Sterling Hanenkamp<br><a href="mailto:sterling@hanenkamp.com">sterling@hanenkamp.com</a><br>785.370.4454<br>