You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Ben Collins-Sussman <su...@collab.net> on 2002/07/18 21:47:36 UTC
[PATCH] docstrings on apr_filepath_merge() flags?
I've got a path as a command-line argument, and I'm trying to convert
it to canonical case using apr_filepath_merge:
apr_err = apr_filepath_merge (&truenamed_target, NULL, raw_target,
APR_FILEPATH_TRUENAME, pool);
Unfortunately, this had the side-effect of converting a relative path
into an absolute path.
After some experimentation, I discovered that adding the
APR_FILEPATH_NOTABSOLUTE flag prevented this behavior.
What annoys me is that I *deliberately* ignored this flag, because of
its cryptic docstring:
/** Fail apr_filepath_merge if the merged path is absolute */
#define APR_FILEPATH_NOTABSOLUTE 0x08
I read this docstring, and thought it was talking about somehow
restricting the *inputs* to the function... like forcing the function
to only accept absolute paths, or something. It doesn't make a lot of
sense.
Does anyone mind if I apply this patch?
Index: apr_file_info.h
===================================================================
RCS file: /home/cvs/apr/include/apr_file_info.h,v
retrieving revision 1.32
diff -u -r1.32 apr_file_info.h
--- apr_file_info.h 20 Mar 2002 08:54:43 -0000 1.32
+++ apr_file_info.h 18 Jul 2002 19:46:59 -0000
@@ -299,10 +299,10 @@
*/
#define APR_FILEPATH_SECUREROOT 0x03
-/** Fail apr_filepath_merge if the merged path is relative */
+/** Return an absolute merged path */
#define APR_FILEPATH_NOTRELATIVE 0x04
-/** Fail apr_filepath_merge if the merged path is absolute */
+/** Return a relative merged path */
#define APR_FILEPATH_NOTABSOLUTE 0x08
/** Return the file system's native path format (e.g. path delimiters
Re: [PATCH] docstrings on apr_filepath_merge() flags?
Posted by Ben Collins-Sussman <su...@collab.net>.
Ben Collins-Sussman <su...@collab.net> writes:
> I've got a path as a command-line argument, and I'm trying to convert
> it to canonical case using apr_filepath_merge:
>
> apr_err = apr_filepath_merge (&truenamed_target, NULL, raw_target,
> APR_FILEPATH_TRUENAME, pool);
>
> Unfortunately, this had the side-effect of converting a relative path
> into an absolute path.
>
> After some experimentation, I discovered that adding the
> APR_FILEPATH_NOTABSOLUTE flag prevented this behavior.
>
> What annoys me is that I *deliberately* ignored this flag, because of
> its cryptic docstring:
>
> /** Fail apr_filepath_merge if the merged path is absolute */
> #define APR_FILEPATH_NOTABSOLUTE 0x08
>
> I read this docstring, and thought it was talking about somehow
> restricting the *inputs* to the function... like forcing the function
> to only accept absolute paths, or something. It doesn't make a lot of
> sense.
[Crossposting to svn and apr lists. svn people, read my original mail
to apr above.]
Argh, it seems that this flag doesn't do exactly what I thought.
The flag definitely prevents apr_filepath_merge from absolutizing
everything; but now it actually *errors* if you pass an absolute path
into it!
I need a simple behavior: "accept either relative or absolute input;
and don't change the output at all." That is, relative input produces
relative output, and absolute input produces absolute output. I
*just* want the case canonicalized, no other side-effects. :-)
Does this mean it's time to add another flag?
Re: [PATCH] docstrings on apr_filepath_merge() flags?
Posted by Thom May <th...@planetarytramp.net>.
* Ben Collins-Sussman (sussman@collab.net) wrote :
>
> I've got a path as a command-line argument, and I'm trying to convert
> it to canonical case using apr_filepath_merge:
>
> apr_err = apr_filepath_merge (&truenamed_target, NULL, raw_target,
> APR_FILEPATH_TRUENAME, pool);
>
> Unfortunately, this had the side-effect of converting a relative path
> into an absolute path.
>
> After some experimentation, I discovered that adding the
> APR_FILEPATH_NOTABSOLUTE flag prevented this behavior.
>
> What annoys me is that I *deliberately* ignored this flag, because of
> its cryptic docstring:
>
> /** Fail apr_filepath_merge if the merged path is absolute */
> #define APR_FILEPATH_NOTABSOLUTE 0x08
>
> I read this docstring, and thought it was talking about somehow
> restricting the *inputs* to the function... like forcing the function
> to only accept absolute paths, or something. It doesn't make a lot of
> sense.
>
> Does anyone mind if I apply this patch?
>
+1
-Thom
Re: [PATCH] docstrings on apr_filepath_merge() flags?
Posted by Ben Collins-Sussman <su...@collab.net>.
Ben Collins-Sussman <su...@collab.net> writes:
> I've got a path as a command-line argument, and I'm trying to convert
> it to canonical case using apr_filepath_merge:
>
> apr_err = apr_filepath_merge (&truenamed_target, NULL, raw_target,
> APR_FILEPATH_TRUENAME, pool);
>
> Unfortunately, this had the side-effect of converting a relative path
> into an absolute path.
>
> After some experimentation, I discovered that adding the
> APR_FILEPATH_NOTABSOLUTE flag prevented this behavior.
>
> What annoys me is that I *deliberately* ignored this flag, because of
> its cryptic docstring:
>
> /** Fail apr_filepath_merge if the merged path is absolute */
> #define APR_FILEPATH_NOTABSOLUTE 0x08
>
> I read this docstring, and thought it was talking about somehow
> restricting the *inputs* to the function... like forcing the function
> to only accept absolute paths, or something. It doesn't make a lot of
> sense.
[Crossposting to svn and apr lists. svn people, read my original mail
to apr above.]
Argh, it seems that this flag doesn't do exactly what I thought.
The flag definitely prevents apr_filepath_merge from absolutizing
everything; but now it actually *errors* if you pass an absolute path
into it!
I need a simple behavior: "accept either relative or absolute input;
and don't change the output at all." That is, relative input produces
relative output, and absolute input produces absolute output. I
*just* want the case canonicalized, no other side-effects. :-)
Does this mean it's time to add another flag?
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] docstrings on apr_filepath_merge() flags?
Posted by Ben Collins-Sussman <su...@collab.net>.
"William A. Rowe, Jr." <wr...@rowe-clan.net> writes:
> At 02:47 PM 7/18/2002, Ben Collins-Sussman wrote:
>
> >I've got a path as a command-line argument, and I'm trying to convert
> >it to canonical case using apr_filepath_merge:
> >
> > apr_err = apr_filepath_merge (&truenamed_target, NULL, raw_target,
> > APR_FILEPATH_TRUENAME, pool);
> >
> >Unfortunately, this had the side-effect of converting a relative path
> >into an absolute path.
>
> Per the apr_filepath_merge docs [and if it's not there, it needs to be],
> passing a rootpath of NULL == the cwd. Passing a rootpath of ""
> (empty) means merge raw_target to an empty path.
>
> Please try passing "" to the root path (meaning, merge the path to
> no characters) and see if that solves your problem.
Ah! That did it! Problem all fixed, the exact behavior I wanted.
Sorry for not reading the docs more closely. Hmmm. Actually, the
docs only mention the option of setting rootpath to NULL, not "".
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] docstrings on apr_filepath_merge() flags?
Posted by Ben Collins-Sussman <su...@collab.net>.
"William A. Rowe, Jr." <wr...@rowe-clan.net> writes:
> At 02:47 PM 7/18/2002, Ben Collins-Sussman wrote:
>
> >I've got a path as a command-line argument, and I'm trying to convert
> >it to canonical case using apr_filepath_merge:
> >
> > apr_err = apr_filepath_merge (&truenamed_target, NULL, raw_target,
> > APR_FILEPATH_TRUENAME, pool);
> >
> >Unfortunately, this had the side-effect of converting a relative path
> >into an absolute path.
>
> Per the apr_filepath_merge docs [and if it's not there, it needs to be],
> passing a rootpath of NULL == the cwd. Passing a rootpath of ""
> (empty) means merge raw_target to an empty path.
>
> Please try passing "" to the root path (meaning, merge the path to
> no characters) and see if that solves your problem.
Ah! That did it! Problem all fixed, the exact behavior I wanted.
Sorry for not reading the docs more closely. Hmmm. Actually, the
docs only mention the option of setting rootpath to NULL, not "".
Re: [PATCH] docstrings on apr_filepath_merge() flags?
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
At 02:47 PM 7/18/2002, Ben Collins-Sussman wrote:
>I've got a path as a command-line argument, and I'm trying to convert
>it to canonical case using apr_filepath_merge:
>
> apr_err = apr_filepath_merge (&truenamed_target, NULL, raw_target,
> APR_FILEPATH_TRUENAME, pool);
>
>Unfortunately, this had the side-effect of converting a relative path
>into an absolute path.
Per the apr_filepath_merge docs [and if it's not there, it needs to be],
passing a rootpath of NULL == the cwd. Passing a rootpath of ""
(empty) means merge raw_target to an empty path.
Please try passing "" to the root path (meaning, merge the path to
no characters) and see if that solves your problem.
Perhaps the solution is to disambiguate NULL from Empty("") and
use a flag instead to designate the "Use CWD" behavior instead
of using a NULL arg.
>After some experimentation, I discovered that adding the
>APR_FILEPATH_NOTABSOLUTE flag prevented this behavior.
>
>What annoys me is that I *deliberately* ignored this flag, because of
>its cryptic docstring:
>
> /** Fail apr_filepath_merge if the merged path is absolute */
> #define APR_FILEPATH_NOTABSOLUTE 0x08
I wouldn't have expected that, either. Ick. I'll be happy to delve into
the code so we can grok this.
>I read this docstring, and thought it was talking about somehow
>restricting the *inputs* to the function... like forcing the function
>to only accept absolute paths, or something. It doesn't make a lot of
>sense.
No it doesn't.
>Does anyone mind if I apply this patch?
Please don't. The flags should do exactly what they said. If we aren't
returning a full path, every time that the rootpath argument is either
NULL (cwd) or a specific full path, then the function is wrong, not the
docs.
I need to review the original intents before I toss out any more feedback.
Bill
Re: [PATCH] docstrings on apr_filepath_merge() flags?
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
At 02:47 PM 7/18/2002, Ben Collins-Sussman wrote:
>I've got a path as a command-line argument, and I'm trying to convert
>it to canonical case using apr_filepath_merge:
>
> apr_err = apr_filepath_merge (&truenamed_target, NULL, raw_target,
> APR_FILEPATH_TRUENAME, pool);
>
>Unfortunately, this had the side-effect of converting a relative path
>into an absolute path.
Per the apr_filepath_merge docs [and if it's not there, it needs to be],
passing a rootpath of NULL == the cwd. Passing a rootpath of ""
(empty) means merge raw_target to an empty path.
Please try passing "" to the root path (meaning, merge the path to
no characters) and see if that solves your problem.
Perhaps the solution is to disambiguate NULL from Empty("") and
use a flag instead to designate the "Use CWD" behavior instead
of using a NULL arg.
>After some experimentation, I discovered that adding the
>APR_FILEPATH_NOTABSOLUTE flag prevented this behavior.
>
>What annoys me is that I *deliberately* ignored this flag, because of
>its cryptic docstring:
>
> /** Fail apr_filepath_merge if the merged path is absolute */
> #define APR_FILEPATH_NOTABSOLUTE 0x08
I wouldn't have expected that, either. Ick. I'll be happy to delve into
the code so we can grok this.
>I read this docstring, and thought it was talking about somehow
>restricting the *inputs* to the function... like forcing the function
>to only accept absolute paths, or something. It doesn't make a lot of
>sense.
No it doesn't.
>Does anyone mind if I apply this patch?
Please don't. The flags should do exactly what they said. If we aren't
returning a full path, every time that the rootpath argument is either
NULL (cwd) or a specific full path, then the function is wrong, not the
docs.
I need to review the original intents before I toss out any more feedback.
Bill
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org