Phr0zen_Penguin

Acquiring/Formatting Raw POST Data

Dec 18th, 2014
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.63 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2. #!c:\Perl\bin\perl.exe -w
  3. ##
  4. ## [post.cgi]
  5. ##
  6. ## Acquiring and formatting raw POST Data
  7. ##
  8.  
  9. print 'Content-type: text/html' . "\n\n";
  10.  
  11. read (STDIN, $rawPostData, $ENV{'CONTENT_LENGTH'});
  12.  
  13. @rawPostPairs = split /&/, $rawPostData;
  14.  
  15.     foreach (@rawPostPairs)
  16.     {
  17.         ($key, $val) = split /=/;
  18.  
  19.         # convert URL-encoded characters
  20.         $val =~ s/%([0-9A-Fa-f]{2})/pack ("C", hex ($1))/eg;
  21.         $key =~ s/%([0-9A-Fa-f]{2})/pack ("C", hex ($1))/eg;
  22.  
  23.         # replace + sign with space character
  24.         $val =~ s/\+/ /g;
  25.  
  26.         # assign the value of $val to a variable with the name of the value of $key
  27.         $$key = $val;
  28.     }
  29.  
  30. exit;
Advertisement
Add Comment
Please, Sign In to add comment