# lists all media (MIME) types registered with the IANA, but unfortunately
# many script types (especially proprietary ones) have not registered with
# them, and that list doesn't specify which types are script content anyway.
@SCRIPT_MIME_TYPES= ('application/x-javascript', 'application/x-ecmascript',
'application/x-vbscript', 'application/x-perlscript',
'application/javascript', 'application/ecmascript',
'text/javascript', 'text/ecmascript', 'text/jscript',
'text/livescript', 'text/vbscript', 'text/vbs',
'text/perlscript', 'text/tcl',
'text/x-scriptlet', 'text/scriptlet',
'application/hta',
) ;
# All MIME types in @SCRIPT_MIME_TYPES and @OTHER_TYPES_TO_REGISTER will be
# "registered". Registration helps the script remember which MIME type is
# expected by a page when downloading embedded URLs, e.g. style sheets. Any
# MIME types that need special treatment should be listed here if they're not
# already in @SCRIPT_MIME_TYPES.
# If you write a handler for a new MIME type in proxify_block(), and that type
# isn't already listed in @SCRIPT_MIME_TYPES, then add it here.
# The Perl code in this program supports up to 64 registered MIME types, but
# the JS _proxy_jslib_pack_flags() and _proxy_jslib_unpack_flags() routines
# only support 26. Thus, fix the JS code if there's ever more than 26 types.
# "text/xml" is a special case-- it's used to support the JavaScript class
# XMLHttpRequest . Data downloaded through that should not be proxified,
# even if it's HTML data; it's proxified later when it's added to a document.
# Using the "text/xml" type is part of avoiding that first proxification.
@OTHER_TYPES_TO_REGISTER= ('text/css', 'text/xml') ;
# These are MIME types that we *may* try to rewrite in proxify_block(), e.g.
# to send all URLs back through this script. If a type isn't on this list,
# then we know for certain it should be sent back to the user unchanged,
# which saves time.
# If you write a handler for a new MIME type in proxify_block(), then add the
# type here.
# NOT all the types here are actually supported at this time!
# text/html is not on this list because currently it's handled specially.
@TYPES_TO_HANDLE= ('text/css',
'application/x-javascript', 'application/x-ecmascript',
'application/javascript', 'application/ecmascript',
'text/javascript', 'text/ecmascript',
'text/livescript', 'text/jscript',
) ;
# This is a list of all file extensions that will be disallowed if
# $TEXT_ONLY is set. It's an inexact science. If you want to ban
# other file extensions, you can add more to this list. Note that
# removing extensions from this list won't necessarily allow those
# files through, since there are other ways $TEXT_ONLY is implemented,
# such as only allowing MIME types of text/* .
# The format of this list is one long string, with the extensions
# separated by "|". This is because the string is actually used as
# a regular expression. Don't worry if you don't know what that means.
# Extensions are roughly taken from Netscape's "Helper Preferences" screen
# (but that was in 1996). A more complete list might be made from a
# mime.types file.
$NON_TEXT_EXTENSIONS=
'gif|jpeg|jpe|jpg|tiff|tif|png|bmp|xbm' # images
. '|mp2|mp3|wav|aif|aiff|au|snd' # audios
. '|avi|qt|mov|mpeg|mpg|mpe' # videos
. '|gz|Z|exe|gtar|tar|zip|sit|hqx|pdf' # applications
. '|ram|rm|ra|swf' ; # others
# This is now set directly in footer(), the only place it's used.
# $PROXY_VERSION= '2.1beta15' ;
#--------------------------------------------------------------------------
# End of normal user configuration.
# Now, set or adjust all globals that remain constant for all runs.
#--------------------------------------------------------------------------
# First, set various constants.
# These are used in rfc1123_date() and date_is_after().
@MONTH= qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) ;
@WEEKDAY= qw(Sun Mon Tue Wed Thu Fri Sat Sun) ;
%UN_MONTH= map { lc($MONTH[$_]), $_ } 0..$#MONTH ; # look up by month name
# Create the sets of regular expressions we'll need if we proxify scripts.
# So far, the only script type we proxify is JavaScript.
&set_RE_JS if $PROXIFY_SCRIPTS ;
# Next, make copies of any constant environment variables, and fix as needed.
# SERVER_PORT and SCRIPT_NAME will be constant, and are used in several places.
# Besides, we need SCRIPT_NAME fixed before setting $THIS_SCRIPT_URL.
# SCRIPT_NAME should have a leading slash, but the old CGI "standard" from
# NCSA was unclear on that, so some servers didn't give it a leading
# slash. Here we ensure it has a leading slash.
# Apache has a bug where SCRIPT_NAME is wrong if the PATH_INFO has "//" in it;
# it's set to the script name plus all of PATH_INFO up until its final "//".
# To work around this, truncate SCRIPT_NAME at the first place it matches $0.
# PATH_INFO is also changed to collapse all multiple slashes into a single
=12= |