Package: firefox
Version: 1.5.dfsg-4
Severity: normal
Tags: patch
Firefox cannot open local file if filename includes
URI "reserved" characters("?", "#", etc.)
This problem is not occurs when open a file from
Firefox's menu(File -> Open File...)
For example, running following command:
$ touch "foo?bar.html"
$ firefox --verbose "foo?bar.html"
FIREFOX_DSP=esddsp
APPLICATION_ID=firefox
CMDLINE_DISPLAY=
DISPLAY=:0.0
OPTIONS=file:///tmp/foo?bar.html
DEBUG=0
DEBUGGER=
Running: /usr/lib/firefox/firefox-bin -a firefox file:///tmp/foo?bar.html
And then I got a error message:
File not found
Firefox can't find the file at /tmp/foo?bar.html.
(--verbose option for firefox command is not necessary to reproduce
this problem, but clarify why this problem occurs)
The file path to open is translated to file URI by 'firefox' command.
But file:///tmp/foo?bar.html is not valid as URI because '?' is
a separator in URI.
According to RFC3986(Uniform Resource Identifier (URI): Generic Syntax),
characters that is not allowed in URI must be Percent-Encoded.
And characters that allowed in Path of URI is described in
RFC3986 section 3.3. Path.
So, the characters except following should be percent-encoded:
alphabet(a to z, A to Z)
digits(0 to 9)
- . _ ~ ! $ & ' ( ) * + , = : @ /
"%" and ";" can be used in Path, but is reserved and thus should be
percent-encoded.
"%" is a indicator to percent-encoded character.
";" is... I don't know what ";" means for.
But firefox fails to open a file without percent-encoding ";".
And RFC2396(obsoleted by RFC3986) says:
Each path segment may include a sequence of parameters,
indicated by the semicolon ";" character.
I have attached a patch to fix this problem.
Lastly, sorry for my inaccurate English.
regards,
-- System Information:
Debian Release: testing/unstable
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15-1-k7
Locale: LANG=ja_JP.UTF-8, LC_CTYPE=ja_JP.UTF-8 (charmap=UTF-8)
Versions of packages firefox depends on:
ii debianutils 2.15.2 Miscellaneous utilities specific t
hi fontconfig 2.3.2-1.1 generic font configuration library
ii libatk1.0-0 1.10.3-1 The ATK accessibility toolkit
ii libc6 2.3.5-12 GNU C Library: Shared libraries an
ii libcairo2 1.0.2-3 The Cairo 2D vector graphics libra
hi libfontconfig1 2.3.2-1.1 generic font configuration library
ii libfreetype6 2.1.10-1 FreeType 2 font engine, shared lib
ii libgcc1 1:4.0.2-7 GCC support library
ii libglib2.0-0 2.8.5-1 The GLib library of C routines
ii libgtk2.0-0 2.8.10-1 The GTK+ graphical user interface
ii libidl0 0.8.5-1 library for parsing CORBA IDL file
ii libjpeg62 6b-11 The Independent JPEG Group's JPEG
ii libpango1.0-0 1.10.2-1 Layout and rendering of internatio
ii libpng12-0 1.2.8rel-5 PNG library - runtime
ii libstdc++6 4.0.2-7 The GNU Standard C++ Library v3
ii libx11-6 6.9.0.dfsg.1-3 X Window System protocol client li
ii libxcursor1 1.1.3-1 X cursor management library
ii libxext6 6.9.0.dfsg.1-3 X Window System miscellaneous exte
hi libxft2 2.1.7-1 FreeType-based font drawing librar
ii libxi6 6.9.0.dfsg.1-3 X Window System Input extension li
ii libxinerama1 6.9.0.dfsg.1-3 X Window System multi-head display
ii libxp6 6.9.0.dfsg.1-3 X Window System printing extension
ii libxrandr2 6.9.0.dfsg.1-3 X Window System Resize, Rotate and
ii libxrender1 1:0.9.0.2-1 X Rendering Extension client libra
ii libxt6 6.9.0.dfsg.1-3 X Toolkit Intrinsics
ii psmisc 22.1-1 Utilities that use the proc filesy
ii zlib1g 1:1.2.3-9 compression library - runtime
firefox recommends no packages.
-- no debconf information
--- firefox.orig 2006-01-17 07:30:10.000000000 +0900
+++ firefox 2006-01-17 07:47:50.000000000 +0900
@@ -211,9 +211,9 @@
if [ "$?" -ne "0" ] && [ -e "`pwd`/${opt}" ]; then
opt="`pwd`/${opt}"
fi
- # Replace all spaces by %20 and prepend file:// if it is a valid file
+ # Make it percent-encoded and prepend file:// if it is a valid file
if [ -e "${opt}" ]; then
- opt="file://`echo ${opt} | sed 's/ /%20/g'`"
+ opt="file://$( echo -n "${opt}" | perl -pe "s/([^a-zA-Z0-9-._~\!\\\$&'()*+,=:@\/])/'%'.unpack('H2',\$1)/ge" )"
fi
fi
set "$@" "${opt}"