| 1 | ##---------------------------------------------------------------------------## | ||
| 2 | ## File: | ||
| 3 | ## $Id: mhmimetypes.pl,v 1.22 2011/01/02 11:20:23 ehood Exp $ | ||
| 4 | ## Author: | ||
| 5 | ## Earl Hood mhonarc@mhonarc.org | ||
| 6 | ## Description: | ||
| 7 | ## MIME type mappings. | ||
| 8 | ##---------------------------------------------------------------------------## | ||
| 9 | ## MHonArc -- Internet mail-to-HTML converter | ||
| 10 | ## Copyright (C) 1998,1999 Earl Hood, mhonarc@mhonarc.org | ||
| 11 | ## | ||
| 12 | ## This program is free software; you can redistribute it and/or modify | ||
| 13 | ## it under the terms of the GNU General Public License as published by | ||
| 14 | ## the Free Software Foundation; either version 2 of the License, or | ||
| 15 | ## (at your option) any later version. | ||
| 16 | ## | ||
| 17 | ## This program is distributed in the hope that it will be useful, | ||
| 18 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 19 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 20 | ## GNU General Public License for more details. | ||
| 21 | ## | ||
| 22 | ## You should have received a copy of the GNU General Public License | ||
| 23 | ## along with this program; if not, write to the Free Software | ||
| 24 | ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
| 25 | ## 02111-1307, USA | ||
| 26 | ##---------------------------------------------------------------------------## | ||
| 27 | |||
| 28 | package mhonarc; | ||
| 29 | |||
| 30 | use File::Basename; | ||
| 31 | |||
| 32 | $UnknownExt = 'bin'; | ||
| 33 | |||
| 34 | %CTExt = ( | ||
| 35 | ##----------------------------------------------------------------------- | ||
| 36 | ## Content-Type Extension:Description | ||
| 37 | ##----------------------------------------------------------------------- | ||
| 38 | |||
| 39 | 'application/astound', 'asd:Astound presentation', | ||
| 40 | 'application/envoy', 'evy:Envoy file', | ||
| 41 | 'application/fastman', 'lcc:fastman file', | ||
| 42 | 'application/fractals', 'fif:Fractal Image Format', | ||
| 43 | 'application/iges', 'iges:IGES file', | ||
| 44 | 'application/mac-binhex40', 'hqx:Mac BinHex archive', | ||
| 45 | 'application/mathematica', 'ma:Mathematica Notebook document', | ||
| 46 | 'application/mbedlet', 'mbd:mbedlet file', | ||
| 47 | 'application/ms-excel', 'xls:MS-Excel spreadsheet', | ||
| 48 | 'application/ms-powerpoint', 'ppt:MS-Powerpoint presentation', | ||
| 49 | 'application/ms-project', 'mpp:MS-Project file', | ||
| 50 | 'application/msword', 'doc:MS-Word document', | ||
| 51 | 'application/octet-stream', 'bin:Binary data', | ||
| 52 | 'application/oda', 'oda:ODA file', | ||
| 53 | 'application/pdf', 'pdf:Adobe PDF document', | ||
| 54 | 'application/pgp', 'pgp:PGP message', | ||
| 55 | 'application/pgp-signature', 'pgp:PGP signature', | ||
| 56 | 'application/pkcs7-mime', 'p7m:S/MIME encrypted message', | ||
| 57 | 'application/pkcs7-signature', 'p7s:S/MIME cryptographic signature', | ||
| 58 | 'application/postscript', 'ps,eps,ai:PostScript document', | ||
| 59 | 'application/rtf', 'rtf:RTF file', | ||
| 60 | 'application/sgml', 'sgml:SGML document', | ||
| 61 | 'application/studiom', 'smp:Studio M file', | ||
| 62 | 'application/timbuktu', 'tbt:timbuktu file', | ||
| 63 | 'application/vis5d', 'v5d:Vis5D dataset', | ||
| 64 | 'application/vnd.framemaker', 'fm:FrameMaker document', | ||
| 65 | 'application/vnd.hp-hpgl', 'hpg,hpgl:HPGL file', | ||
| 66 | 'application/vnd.lotus-1-2-3', '123,wk4,wk3,wk1:Lotus 1-2-3', | ||
| 67 | 'application/vnd.lotus-approach', 'apr,vew:Lotus Approach', | ||
| 68 | 'application/vnd.lotus-freelance', 'prz,pre:Lotus Freelance', | ||
| 69 | 'application/vnd.lotus-organizer', 'org,or3,or2:Lotus Organizer', | ||
| 70 | 'application/vnd.lotus-screencam', 'scm:Lotus Screencam', | ||
| 71 | 'application/vnd.lotus-wordpro', 'lwp,sam:Lotus WordPro', | ||
| 72 | 'application/vnd.mif', 'mif:Frame MIF document', | ||
| 73 | 'application/vnd.ms-excel', 'xls:MS-Excel spreadsheet', | ||
| 74 | 'application/vnd.ms-powerpoint', 'ppt:MS-Powerpoint presentation', | ||
| 75 | 'application/vnd.ms-project', 'mpp:MS-Project file', | ||
| 76 | 'application/vnd.stardivision.calc', 'sdc:StarCalc spreadsheet', | ||
| 77 | 'application/vnd.stardivision.chart', 'sds:StarChart document', | ||
| 78 | 'application/vnd.stardivision.draw', 'sda:StarDraw document', | ||
| 79 | 'application/vnd.stardivision.impress-packed', | ||
| 80 | 'sdp:StarImpress packed file', | ||
| 81 | 'application/vnd.stardivision.impress', 'sdd:StarImpress presentation', | ||
| 82 | 'application/vnd.stardivision.mail', 'smd:StarMail mail file', | ||
| 83 | 'application/vnd.stardivision.math', 'smf:StarMath document', | ||
| 84 | 'application/vnd.stardivision.writer-global', | ||
| 85 | 'sgl:StarWriter global document', | ||
| 86 | 'application/vnd.stardivision.writer', 'sdw:StarWriter document', | ||
| 87 | 'application/vnd.sun.xml.calc', 'sxc:OpenOffice Calc spreadsheet', | ||
| 88 | 'application/vnd.sun.xml.calc.template', 'stc:OpenOffice Calc template', | ||
| 89 | 'application/vnd.sun.xml.draw', 'sxd:OpenOffice Draw document', | ||
| 90 | 'application/vnd.sun.xml.draw.template', 'std:OpenOffice Draw Template', | ||
| 91 | 'application/vnd.sun.xml.impress', 'sxi:OpenOffice Impress presentation', | ||
| 92 | 'application/vnd.sun.xml.impress.template', | ||
| 93 | 'sti:OpenOffice Impress template', | ||
| 94 | 'application/vnd.sun.xml.math', 'sxm:OpenOffice Math documents', | ||
| 95 | 'application/vnd.sun.xml.writer.global', | ||
| 96 | 'sxg:OpenOffice Writer global document', | ||
| 97 | 'application/vnd.sun.xml.writer', 'sxw:OpenOffice Writer document', | ||
| 98 | 'application/vnd.sun.xml.writer.template', | ||
| 99 | 'stw:OpenOffice Write template', | ||
| 100 | 'application/winhlp', 'hlp:WinHelp document', | ||
| 101 | 'application/wordperfect5.1', 'wp:WordPerfect 5.1 document', | ||
| 102 | 'application/x-asap', 'asp:asap file', | ||
| 103 | 'application/x-bcpio', 'bcpio:BCPIO file', | ||
| 104 | 'application/x-bzip2', 'bz2:BZip2 compressed data', | ||
| 105 | 'application/x-compress', 'Z:Unix compressed data', | ||
| 106 | 'application/x-cpio', 'cpio:CPIO file', | ||
| 107 | 'application/x-csh', 'csh:C-Shell script', | ||
| 108 | 'application/x-dot', 'dot:dot file', | ||
| 109 | 'application/x-dvi', 'dvi:TeX dvi file', | ||
| 110 | 'application/x-earthtime', 'etc:Earthtime file', | ||
| 111 | 'application/x-envoy', 'evy:Envoy file', | ||
| 112 | 'application/x-excel', 'xls:MS-Excel spreadsheet', | ||
| 113 | 'application/x-gtar', 'gtar:GNU Unix tar archive', | ||
| 114 | 'application/x-gzip', 'gz:GNU Zip compressed data', | ||
| 115 | 'application/x-hdf', 'hdf:HDF file', | ||
| 116 | 'application/x-javascript', 'js:JavaScript source', | ||
| 117 | 'application/x-ksh', 'ksh:Korn Shell script', | ||
| 118 | 'application/x-latex', 'latex:LaTeX document', | ||
| 119 | 'application/x-maker', 'fm:FrameMaker document', | ||
| 120 | 'application/x-mif', 'mif:Frame MIF document', | ||
| 121 | 'application/x-mocha', 'moc:mocha file', | ||
| 122 | 'application/x-msaccess', 'mdb:MS-Access database', | ||
| 123 | 'application/x-mscardfile', 'crd:MS-CardFile', | ||
| 124 | 'application/x-msclip', 'clp:MS-Clip file', | ||
| 125 | 'application/x-msmediaview', 'm14:MS-Media View file', | ||
| 126 | 'application/x-msmetafile', 'wmf:MS-Metafile', | ||
| 127 | 'application/x-msmoney', 'mny:MS-Money file', | ||
| 128 | 'application/x-mspublisher', 'pub:MS-Publisher document', | ||
| 129 | 'application/x-msschedule', 'scd:MS-Schedule file', | ||
| 130 | 'application/x-msterminal', 'trm:MS-Terminal', | ||
| 131 | 'application/x-mswrite', 'wri:MS-Write document', | ||
| 132 | 'application/x-netcdf', 'cdf:Cdf file', | ||
| 133 | 'application/x-net-install', 'ins:Net Install file', | ||
| 134 | 'application/x-ns-proxy-autoconfig', 'proxy:Netscape Proxy Auto Config', | ||
| 135 | 'application/x-patch', 'patch:Source code patch', | ||
| 136 | 'application/x-perl', 'pl:Perl program', | ||
| 137 | 'application/x-pointplus', 'css:pointplus file', | ||
| 138 | 'application/x-salsa', 'slc:salsa file', | ||
| 139 | 'application/x-script', 'script:A script file', | ||
| 140 | 'application/x-shar', 'shar:Unix shell archive', | ||
| 141 | 'application/x-sh', 'sh:Bourne shell script', | ||
| 142 | 'application/x-sprite', 'spr:sprite file', | ||
| 143 | 'application/x-stuffit', 'sit:Macintosh archive', | ||
| 144 | 'application/x-sv4cpio', 'sv4cpio:SV4Cpio file', | ||
| 145 | 'application/x-sv4crc', 'sv4crc:SV4Crc file', | ||
| 146 | 'application/x-tar', 'tar:Unix tar archive', | ||
| 147 | 'application/x-tcl', 'tcl:Tcl script', | ||
| 148 | 'application/x-texinfo', 'texinfo:TeXInfo document', | ||
| 149 | 'application/x-tex', 'tex:TeX document', | ||
| 150 | 'application/x-timbuktu', 'tbp:timbuktu file', | ||
| 151 | 'application/x-tkined', 'tki:tkined file', | ||
| 152 | 'application/x-troff-man', 'man:Unix manual page', | ||
| 153 | 'application/x-troff-me', 'me:Troff ME-macros document', | ||
| 154 | 'application/x-troff-ms', 'ms:Troff MS-macros document', | ||
| 155 | 'application/x-troff', 'roff:Troff document', | ||
| 156 | 'application/x-ustar', 'ustar:UStar file', | ||
| 157 | 'application/x-wais-source', 'src:WAIS Source', | ||
| 158 | 'application/x-zip-compressed', 'zip:Zip compressed data', | ||
| 159 | 'application/xml', 'xml:XML document', | ||
| 160 | 'application/zip', 'zip:Zip archive', | ||
| 161 | |||
| 162 | 'audio/basic', 'snd:Basic audio', | ||
| 163 | 'audio/echospeech', 'es:Echospeech audio', | ||
| 164 | 'audio/microsoft-wav', 'wav:Wave audio', | ||
| 165 | 'audio/midi', 'midi:MIDI audio', | ||
| 166 | 'audio/wav', 'wav:Wave audio', | ||
| 167 | 'audio/x-aiff', 'aif,aiff,aifc:AIF audio', | ||
| 168 | 'audio/x-epac', 'pae:epac audio', | ||
| 169 | 'audio/x-midi', 'midi:MIDI audio', | ||
| 170 | 'audio/x-mpeg', 'mp2:MPEG audio', | ||
| 171 | 'audio/x-pac', 'pac:pac audio', | ||
| 172 | 'audio/x-pn-realaudio', 'ra,ram:PN Realaudio', | ||
| 173 | 'audio/x-wav', 'wav:Wave audio', | ||
| 174 | |||
| 175 | 'chemical/chem3d', 'c3d:Chem3d chemical test', | ||
| 176 | 'chemical/chemdraw', 'chm:Chemdraw chemical test', | ||
| 177 | 'chemical/cif', 'cif:CIF chemical test', | ||
| 178 | 'chemical/cml', 'cml:CML chemical test', | ||
| 179 | 'chemical/cmsl', 'cml:Chemical Structure Markup', | ||
| 180 | 'chemical/cxf', 'cxf:Chemical Exhange Format file', | ||
| 181 | 'chemical/daylight-smiles', 'smi:SMILES format file', | ||
| 182 | 'chemical/embl-dl-nucleotide', 'emb,embl:EMBL nucleotide format file', | ||
| 183 | 'chemical/gaussian', 'gau:Gaussian data', | ||
| 184 | 'chemical/gaussian-input', 'gau:Gaussian input data', | ||
| 185 | 'chemical/gaussian-log', 'gal:Gaussian log', | ||
| 186 | 'chemical/gcg8-sequence', 'gcg:GCG format file', | ||
| 187 | 'chemical/genbank', 'gen:GENbank data', | ||
| 188 | 'chemical/jcamp-dx', 'jdx:Jcamp chemical spectra test', | ||
| 189 | 'chemical/kinemage', 'kin:Kinemage', | ||
| 190 | 'chemical/macromodel-input', 'mmd,mmod:Macromodel chemical test', | ||
| 191 | 'chemical/mopac-input', 'gau:Mopac chemical test', | ||
| 192 | 'chemical/mdl-molfile', 'mol:MOL mdl chemical test', | ||
| 193 | 'chemical/mdl-rdf', 'rdf:RDF chemical test', | ||
| 194 | 'chemical/mdl-rxn', 'rxn:RXN chemical test', | ||
| 195 | 'chemical/mdl-sdf', 'sdf:SDF chemical test', | ||
| 196 | 'chemical/mdl-tgf', 'tgf:TGF chemical test', | ||
| 197 | 'chemical/mif', 'mif:MIF chemical test', | ||
| 198 | 'chemical/mmd', 'mmd:Macromodel data', | ||
| 199 | 'chemical/mopac-input', 'mop:MOPAC data ', | ||
| 200 | 'chemical/ncbi-asn1', 'asn:NCBI data', | ||
| 201 | 'chemical/ncbi-asn1-binary', 'val:NCBI data', | ||
| 202 | 'chemical/pdb', 'pdb:Protein Databank data', | ||
| 203 | 'chemical/rosdal', 'ros:Rosdal data', | ||
| 204 | 'chemical/xyz', 'xyz:Xmol XYZ data', | ||
| 205 | |||
| 206 | 'image/bmp', 'bmp:Windows bitmap', | ||
| 207 | 'image/cgm', 'cgm:Computer Graphics Metafile', | ||
| 208 | 'image/fif', 'fif:Fractal Image Format image', | ||
| 209 | 'image/g3fax', 'g3f:Group III FAX image', | ||
| 210 | 'image/gif', 'gif:GIF image', | ||
| 211 | 'image/ief', 'ief:IEF image', | ||
| 212 | 'image/ifs', 'ifs:IFS image', | ||
| 213 | 'image/jpeg', 'jpg,jpeg,jpe:JPEG image', | ||
| 214 | 'image/pbm', 'pbm:Portable bitmap', | ||
| 215 | 'image/pgm', 'pgm:Portable graymap', | ||
| 216 | 'image/png', 'png:PNG image', | ||
| 217 | 'image/tiff', 'tif,tiff:TIFF image', | ||
| 218 | 'image/vnd', 'dwg:VND image', | ||
| 219 | 'image/wavelet', 'wi:Wavelet image', | ||
| 220 | 'image/x-cmu-raster', 'ras:CMU raster', | ||
| 221 | 'image/x-pbm', 'pbm:Portable bitmap', | ||
| 222 | 'image/x-pcx', 'pcx:PCX image', | ||
| 223 | 'image/x-pgm', 'pgm:Portable graymap', | ||
| 224 | 'image/x-pict', 'pict:Mac PICT image', | ||
| 225 | 'image/x-pnm', 'pnm:Portable anymap', | ||
| 226 | 'image/x-portable-anymap', 'pnm:Portable anymap', | ||
| 227 | 'image/x-portable-bitmap', 'pbm:Portable bitmap', | ||
| 228 | 'image/x-portable-graymap', 'pgm:Portable graymap', | ||
| 229 | 'image/x-portable-pixmap', 'ppm:Portable pixmap', | ||
| 230 | 'image/x-ppm', 'ppm:Portable pixmap', | ||
| 231 | 'image/x-rgb', 'rgb:RGB image', | ||
| 232 | 'image/x-xbitmap', 'xbm:X bitmap', | ||
| 233 | 'image/x-xbm', 'xbm:X bitmap', | ||
| 234 | 'image/x-xpixmap', 'xpm:X pixmap', | ||
| 235 | 'image/x-xpm', 'xpm:X pixmap', | ||
| 236 | 'image/xwd', 'xwd:X window dump', | ||
| 237 | 'image/xwindowdump', 'xwd:X window dump', | ||
| 238 | |||
| 239 | 'message/rfc822', '822:Mail message', | ||
| 240 | 'message/news', '822:News post', | ||
| 241 | |||
| 242 | 'model/iges', 'iges:IGES model', | ||
| 243 | 'model/vrml', 'wrl:VRML model', | ||
| 244 | 'model/mesh', 'mesh:Mesh model', | ||
| 245 | |||
| 246 | 'text/enriched', 'rtx:Text-enriched document', | ||
| 247 | 'text/html', 'html:HTML document', | ||
| 248 | 'text/plain', 'txt:Text document', | ||
| 249 | 'text/richtext', 'rtx:Richtext document', | ||
| 250 | 'text/setext', 'stx:Setext document', | ||
| 251 | 'text/sgml', 'sgml:SGML document', | ||
| 252 | 'text/tab-separated-values', 'tsv:Tab separated values', | ||
| 253 | 'text/x-speech', 'talk:Speech document', | ||
| 254 | 'text/x-vcard', 'vcf:Vcard', | ||
| 255 | 'text/xml', 'xml:XML document', | ||
| 256 | |||
| 257 | 'video/isivideo', 'fvi:isi video', | ||
| 258 | 'video/mpeg', 'mpg,mpeg,mpe:MPEG movie', | ||
| 259 | 'video/msvideo', 'avi:MS Video', | ||
| 260 | 'video/quicktime', 'mov,qt:QuickTime movie', | ||
| 261 | 'video/vivo', 'viv:vivo video', | ||
| 262 | 'video/wavelet', 'wv:Wavelet video', | ||
| 263 | 'video/x-sgi-movie', 'movie:SGI movie', | ||
| 264 | |||
| 265 | ); | ||
| 266 | |||
| 267 | ##--------------------------------------------------------------------------- | ||
| 268 | ## get_mime_ext(): Get the prefered filename extension and a | ||
| 269 | ## a brief description of a given mime type. | ||
| 270 | ## | ||
| 271 | sub get_mime_ext { | ||
| 272 | my $ctype = lc shift; | ||
| 273 | my ($ext, $desc) = (undef, undef); | ||
| 274 | |||
| 275 | if (defined($CTExt{$ctype})) { | ||
| 276 | ($ext, $desc) = split(/:/, $CTExt{$ctype}, 2); | ||
| 277 | } elsif (($ctype =~ s|/x-|/|) && defined($CTExt{$ctype})) { | ||
| 278 | ($ext, $desc) = split(/:/, $CTExt{$ctype}, 2); | ||
| 279 | } | ||
| 280 | if (defined($ext)) { | ||
| 281 | $ext = (split(/,/, $ext))[0]; | ||
| 282 | } elsif ($ctype =~ /^text\//) { | ||
| 283 | $ext = 'txt'; | ||
| 284 | $desc = 'Text Data'; | ||
| 285 | } else { | ||
| 286 | $ext = $UnknownExt; | ||
| 287 | $desc = $ctype; | ||
| 288 | } | ||
| 289 | ($ext, $desc); | ||
| 290 | } | ||
| 291 | |||
| 292 | ##--------------------------------------------------------------------------- | ||
| 293 | ## write_attachment(): Write data to a file with a given content-type. | ||
| 294 | ## Function can be used by content-type filters for writing data | ||
| 295 | ## to a file. | ||
| 296 | ## | ||
| 297 | sub write_attachment { | ||
| 298 | my $content = lc shift; # Content-type | ||
| 299 | my $sref = shift; # Reference to data | ||
| 300 | my $opt = ref($_[0]) ? shift : +{@_}; | ||
| 301 | |||
| 302 | my $path = $opt->{'-dirpath'} || ''; | ||
| 303 | my $fname = $opt->{'-filename'} || ''; | ||
| 304 | my $inext = $opt->{'-ext'} || ''; | ||
| 305 | my $url = $opt->{'-url'} || $AttachmentUrl || ''; | ||
| 306 | |||
| 307 | my $pathname = $AttachmentDir; | ||
| 308 | my $rel_outdir = 0; | ||
| 309 | if (!$pathname) { | ||
| 310 | $pathname = $OUTDIR; | ||
| 311 | $rel_outdir = 1; | ||
| 312 | } elsif (!OSis_absolute_path($pathname)) { | ||
| 313 | $pathname = $OUTDIR . $DIRSEP . $pathname; | ||
| 314 | $rel_outdir = 1; | ||
| 315 | } | ||
| 316 | |||
| 317 | my $ctype = 'application/octet-stream'; | ||
| 318 | if ($content =~ m%^\s*([\w\-\./]+)%) { | ||
| 319 | $ctype = $1; | ||
| 320 | } | ||
| 321 | |||
| 322 | if ($path) { | ||
| 323 | if (OSis_absolute_path($path)) { | ||
| 324 | $pathname = $path; | ||
| 325 | $rel_outdir = 0; | ||
| 326 | } else { | ||
| 327 | $pathname .= $DIRSEP . $path; | ||
| 328 | $url .= '/' if ($url); | ||
| 329 | $url .= urlize_file_path($path); | ||
| 330 | } | ||
| 331 | } | ||
| 332 | dir_create($pathname); | ||
| 333 | |||
| 334 | my $ext; | ||
| 335 | if (!$fname) { | ||
| 336 | $ext = $inext || (get_mime_ext($ctype))[0]; | ||
| 337 | } else { | ||
| 338 | # Convert invalid characters in filename to underscores | ||
| 339 | $fname =~ tr/\0-\40\t\n\r?:\57\134*"'<>|\177-\377/_/; | ||
| 340 | } | ||
| 341 | |||
| 342 | ## Write to random file first | ||
| 343 | my ($fh, $tmpfile) = | ||
| 344 | file_temp($ext . 'XXXXXXXXXX', $pathname, '.' . $ext); | ||
| 345 | binmode($fh); | ||
| 346 | print $fh $$sref; | ||
| 347 | close($fh); | ||
| 348 | |||
| 349 | ## Set pathname for file | ||
| 350 | if ($fname) { | ||
| 351 | # need to rename to desired filename | ||
| 352 | $pathname .= $DIRSEP . $fname; | ||
| 353 | if (!rename($tmpfile, $pathname)) { | ||
| 354 | die qq/ERROR: Unable to rename "$tmpfile" to "$pathname": $!\n/; | ||
| 355 | } | ||
| 356 | } else { | ||
| 357 | # just use random filename | ||
| 358 | $pathname = $tmpfile; | ||
| 359 | $fname = basename($tmpfile); | ||
| 360 | } | ||
| 361 | $url .= '/' if ($url); | ||
| 362 | $url .= urlize_file_path($fname); | ||
| 363 | file_chmod($pathname); | ||
| 364 | |||
| 365 | if ($rel_outdir) { | ||
| 366 | $pathname = $path; | ||
| 367 | $pathname .= $DIRSEP if ($pathname); | ||
| 368 | $pathname .= $fname; | ||
| 369 | $url = join('/', $OUTDIR, $url) if $SINGLE; | ||
| 370 | } | ||
| 371 | ($pathname, $url); | ||
| 372 | } | ||
| 373 | |||
| 374 | ##--------------------------------------------------------------------------- | ||
| 375 | ## Convert a filesystem path into a URL path. | ||
| 376 | ## | ||
| 377 | sub urlize_file_path { | ||
| 378 | my $path = shift; | ||
| 379 | $path =~ s/$DIRSEPREX/\//go; | ||
| 380 | $path =~ s/([^\w.\-\/])/sprintf("%%%X",unpack("C",$1))/ge; | ||
| 381 | $path; | ||
| 382 | } | ||
| 383 | |||
| 384 | ##--------------------------------------------------------------------------- | ||
| 385 | |||
| 386 | sub dump_ctext_hash { | ||
| 387 | local ($_); | ||
| 388 | foreach (sort keys %CTExt) { | ||
| 389 | print STDERR $_, ":", $CTExt{$_}, "\n"; | ||
| 390 | } | ||
| 391 | } | ||
| 392 | |||
| 393 | ##--------------------------------------------------------------------------- | ||
| 394 | 1; |