Kalle Olavi Niemitalo wrote:
> Michael Sinz <Michael.Sinz@sinz.org> writes:
>
>>Michael Sinz wrote:
>>
>>>Kalle Olavi Niemitalo wrote:
>>>
>>>>Are the "href" attributes in the XML output even documented to be
>>>>URLs?
>>>
>>> From what I know, they are "relative" URLs, specifically formatted
>>>(and escaped) to be that. (Check out subversion/mod_dav_svn/repos.c around
>>>line 3331 or so.)
>>
>> ^^^^ - make that line 2461 in r16897 in /trunk.
>
>
> Okay. This is in subversion/mod_dav_svn/repos.c (dav_svn_deliver):
>
> | /* We quote special characters in both XML and HTML. */
> | name = apr_xml_quote_string(entry_pool, name, !gen_html);
> |
> | href = ap_escape_uri(entry_pool, href);
> | href = apr_xml_quote_string(entry_pool, href, 1);
>
> httpd-2.0.53/include/httpd.h says:
>
> | /**
> | * Escape a path segment, as defined in RFC 1808
> | * @param p The pool to allocate from
> | * @param s The path to convert
> | * @return The converted URL
> | */
> | AP_DECLARE(char *) ap_escape_path_segment(apr_pool_t *p, const char *s);
> | /**
> | * convert an OS path to a URL in an OS dependant way.
> | * @param p The pool to allocate from
> | * @param path The path to convert
> | * @param partial if set, assume that the path will be appended to something
> | * with a '/' in it (and thus does not prefix "./")
> | * @return The converted URL
> | */
> | AP_DECLARE(char *) ap_os_escape_path(apr_pool_t *p, const char *path, int partial);
> | /** @see ap_os_escape_path */
> | #define ap_escape_uri(ppool,path) ap_os_escape_path(ppool,path,1)
>
> httpd-2.0.53/server/util.c (ap_os_escape_path) checks for colons
> if partial==0. So the following patch (which I cannot test now)
> should fix this.
Well, it fixes it by prepending the "./" to the element, much like
my kludge patch, only with less overhead (same new allocation) and with
the "./" prepended only if there is a ":" before any "/"
So, yes, this looks like a good way to fix this. (My other way was to
%3A the ":" but that is not needed by using the ap_os_escape_path() function.
(I should have seen that - I was looking at using ap_escape_path_segment()
before appending the "/" since we know the path segment is just that but
it still does not escape the ":" since it seems Apache does not escape ":"
but depends on the fact that there will be a "/" before any ":" in the path.)
---- Output from mod_dav_svn in HTML mode - XML is equally fixed. ----
<html><head><title>Revision 31: /trunk/tests</title></head>
<body>
<h2>Revision 31: /trunk/tests</h2>
<ul>
<li>..</li>
<li>.svn_index</li>
<li>TestCase- -/</li>
<li>TestCase-!-/</li>
<li>TestCase-"-/</li>
<li>TestCase-#-/</li>
<li>TestCase-$-/</li>
<li>TestCase-%-/</li>
<li>TestCase-&-/</li>
<li>TestCase-'-/</li>
<li>TestCase-(-/</li>
<li>TestCase-)-/</li>
<li>TestCase-*-/</li>
<li>TestCase-+-/</li>
<li>TestCase-,-/</li>
<li>TestCase---/</li>
<li>TestCase-.-/</li>
<li>TestCase-:-/</li>
<li>TestCase-;-/</li>
<li>TestCase-<-/</li>
<li>TestCase-=-/</li>
<li>TestCase->-/</li>
<li>TestCase-?-/</li>
<li>TestCase-@-/</li>
<li>TestCase-[-/</li>
<li>TestCase-\-/</li>
<li>TestCase-]-/</li>
<li>TestCase-^-/</li>
<li>TestCase-_-/</li>
<li>TestCase-`-/</li>
<li>TestCase-mv/</li>
<li>TestCase-{-/</li>
<li>TestCase-|-/</li>
<li>TestCase-}-/</li>
<li>TestCase-~-/</li>
<li>TestCase--/</li>
<li>mkdirs.pl</li>
</ul>
<hr noshade><em>Powered by Subversion version 1.2.3 (r15833).</em>
</body></html>
----------------------------------------------------------------------
I would like to suggest that this be back-ported to 1.2.x and 1.3.x since
it is needed to make files and directories with ":" in them work correctly
in the mod_dav_svn HTML and XML output. I guess I should write up a formal
patch...
Index: subversion/mod_dav_svn/repos.c
===================================================================
--- subversion/mod_dav_svn/repos.c (revision 16897)
+++ subversion/mod_dav_svn/repos.c (working copy)
@@ -2458,7 +2458,7 @@
/* We quote special characters in both XML and HTML. */
name = apr_xml_quote_string(entry_pool, name, !gen_html);
- href = ap_escape_uri(entry_pool, href);
+ href = ap_os_escape_path(entry_pool, href, 0);
href = apr_xml_quote_string(entry_pool, href, 1);
if (gen_html)
===================================================================
> Another option would be to call ap_escape_path_segment and append
> the slash only afterward, but then it would have to be appended
> separately to both name and href, leading to more complex code.
As I said, I tried that - but ap_escape_path_segment() does not deal with
the ":" in any way. It assumes that a "/" before it will effectively
make the ":" not a special character as per the URL/URI specification.
Thus, the only real "escaping" of the ":" is using "partial = 0" in the
ap_os_escape_path() function - and it only prepends the "./" to make that
work.
--
Michael Sinz Technology and Engineering Director/Consultant
"Starting Startups" mailto:michael.sinz@sinz.org
My place on the web http://www.sinz.org/Michael.Sinz
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 22 14:40:35 2005