Chapter 13. Example of external parser

This is a trivial example of how to write an external parser; this will replace any page with the word "sex" in it with a warning message (shrug).This should be used with the type set to "File", Mimetype set to "text/html", and Newmime set to "STDIN"

--- SNIP ---

      #!/bin/sh
      if grep -i sex $1 > /dev/null; then
      echo "Content-Type: text/html"
      echo ""
      echo "<html><head><title>Inappropriate content</title></head>"
      echo "<body><font size=6>$HTTP_HOST$HTTP_FILE contains inappropriate content</font></body>"
      echo "</html>"
      exit 0
      fi
      # Non-zero exit status returns original content
      exit 1
      # Alternatively, you can send a Content-type header with the same MIME-type as the original document and cat the file (slower)
      echo "Content-type: $SERVER_CONTENT_TYPE"
      echo ""
      cat $1

--- SNIP ---