100% Spam Free Email | Contact Us | Products/Services | Korn Shell | MicroEMACS


AIXtm mtXIA Technical Consulting Group

 


cgiparse

Korn Shell 93 function to parse CGI variables containing encoded HEX characters


Path : Home : Tools : Scripts : Korn : Functions


Current:cgiparse
Previous:.
Home Page

shcurses
frenchMenus



################################################################
####
#### Program: cgiparse
#### 
#### Description: Korn Shell 93 function to parse CGI variables 
#### containing encoded HEX characters.  Initializes CGI 
#### variables with their assigned values into the current
#### shell environment.  If no CGI variable is passed, then
#### the parsed CGI string is sent to standard output.
####
#### Description:	Version 0.2	
####
#### Author:	Dana French (dfrench@mtxia.com)
####		615.556.0456
####
#### Date:		20061024
####
#### Usage: 
#### 
####   IFS="&" PARSED=( ${QUERY_STRING} )
####   for VAR in "${PARSED[@]}"
####   do
####     print "${VAR}" | cgiparse
####   done
####
################################################################
function cgiparse_k93
{
  typeset CGILINE
  typeset CGITMP
  typeset CGIVAR
  typeset CGIVAL
  CGIIFS="${IFS}"
  IFS=''
  while read -r -- CGILINE
  do
    CGITMP="${CGILINE//+/ }"
    CGITMP="${CGITMP//%([A-Za-z0-9][A-Za-z0-9])/\$( printf "'\\\0%o'" 0x\1 )}"
    CGIVAR="${CGITMP%%=*}"
    CGIVAL="${CGITMP#*=}"
    CGITMP="${CGIVAR}=\"\\\"${CGIVAL}\\\"\""
    [[ "${CGITMP}" = *=* ]] &&
      eval $( eval print -- "${CGITMP}" ) ||
      eval print -- "${CGITMP}"
  done
  IFS="${CGIIFS}"
}
################################################################

 

For information regarding this page, contact Dana French ( dfrench@mtxia.com )
Copyright 2008 by Mt Xia Inc, All Rights Reserved