Re: When and why should I escape a path string?
- From: Alexander Larsson <alexl redhat com>
- To: Matthias Kaeppler <matthias finitestate org>
- Cc: gnome-vfs-list gnome org
- Subject: Re: When and why should I escape a path string?
- Date: Thu, 03 Nov 2005 10:41:14 +0100
On Tue, 2005-11-01 at 11:10 +0100, Matthias Kaeppler wrote:
> Hi,
>
> I just encountered a bug in my program, where I would try to create a
> Gnome::Vfs::Uri from an escaped path (the directory in question was the
> 'lost+found' directory which is found on ext3 partitions and which was
> converted by gnome-vfs to 'lost%2Bfound'). I was getting exceptions
> thrown at me when trying to create an URI from this string ("file does
> not exist").
>
> After unescaping the string, creating an URI from it worked. So when and
> why am I supposed to use escaped paths? Obviously, gnome-vfs somewhere
> internally already escaped the path, so it should be able to deal with
> them. But then, why does creating an URI from an escaped path fail? ^^
It varies a bit. For instance gnome_vfs_uri_extract_short_name gets the
unescaped file name, while gnome_vfs_uri_extract_short_path_name gives
you the escaped version. You have to take care for each call that takes
a filename to make sure you have the right form, which should be
specified in the docs.
However, whenever you're passing full URIs they *must* be escaped, as
otherwise they are not valid uris. The exception of course are helper
functions like gnome_vfs_make_uri_from_input() that are made to convert
invalid user-specified uris into real uris.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Alexander Larsson Red Hat, Inc
alexl redhat com alla lysator liu se
He's an all-American day-dreaming inventor with a winning smile and a way with
the ladies. She's a strong-willed French-Canadian opera singer who hides her
beauty behind a pair of thick-framed spectacles. They fight crime!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]