url - A html space is showing as %2520 instead of %20 -
passing filename firefox browser causes replace spaces %2520
instead of %20
.
i have following html in file called myhtml.html
:
<img src="c:\documents , settings\screenshots\image01.png"/>
when load myhtml.html
firefox, image shows broken image. right click link view picture , shows modified url:
file:///c:/documents%2520and%2520settings/screenshots/image01.png ^ ^-----firefox changed space %2520.
what heck? converted space %2520
. shouldn't converting %20
?
how change html file browser can find image? what's going on here?
a bit of explaining %2520
:
the common space character encoded %20
noted yourself. %
character encoded %25
.
the way %2520
when url has %20
in it, , gets urlencoded again, transforms %20
%2520
.
are (or framework might using) double encoding characters?
edit: expanding bit on this, local links. assuming want link resource c:\my path\my file.html
:
- if provide local file path only, browser expected encode , protect characters given (in above, should give spaces shown, since
%
valid filename character , such encoded) when converting proper url (see next point). - if provide url
file://
protocol, stating have taken precautions , encoded needs encoding, rest should treated special characters. in above example, should providefile:///c:/my%20path/my%20file.html
. aside fixing slashes, clients should not encode characters here.
notes:
- slash direction - forward slashes
/
used in urls, reverse slashes\
in windows paths, clients work both converting them proper forward slash. - in addition, there 3 slashes after protocol name, since silently referring current machine instead of remote host ( full unabbreviated path
file://localhost/c:/my%20path/my%file.html
), again clients work without host part (ie 2 slashes only) assuming mean local machine , adding third slash.
Comments
Post a Comment