[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: valid filenames

From: Stephen Connolly <stephen.alan.connolly_at_gmail.com>
Date: Fri, 22 May 2009 09:09:26 +0100

2009/5/22 Ryan Schmidt <subversion-2009b_at_ryandesign.com>

> On May 21, 2009, at 17:12, Stephen Connolly wrote:
>
> On May 21, 2009, at 15:45, Andrey Repin wrote:
>>
>> On May 21, 2009, at 15:06, Tyler Roscoe wrote:
>>>
>>> On May 21, 2009, at 15:02, Stephen Connolly wrote:
>>>>
>>>> does svn support filenames containing /
>>>>>
>>>>> ie on unix
>>>>>
>>>>> fish\/clam.doc
>>>>>
>>>>
>>>> Since / is not allowed in filenames on any Unix I've ever used, my
>>>> answer would be "No, and if it does it's a terrible idea to use this
>>>> 'feature'."
>>>>
>>>
>>> Neither on Windows. (moreover, for dos/windows, forward and backward
>>> slashes
>>> are interchangeable)
>>>
>>
>> I don't want to create a filename with a slash in it. I want to ensure
>> that when encoding a path in an URL, I don't have to worry about
>> escaping slashes
>>
>
> I'm having a little trouble understanding your question. Maybe if you gave
> an example. But I think the answer is probably that things will "just work"
> as they should. Of course you can (and should) create a test repository and
> try everything out, and then email us with specific questions if you find
> something that doesn't work as you expected (showing us the commands you
> typed, what you got, and what you expected to get).
>
>
>
>
I am one of the developers of Hudson. I wrote the integration for sventon.

For sventon 1.x they took the svn path as an url parameter, so you just used
URLEncoder.encode(path, "UTF-8") to pass the path.

For sventon 2.x they switched to making the svn path part of the path
portion of the URL, so if you use URLEncoder.encode(path, "UTF-8") to encode
the path... (which you need to at least partly do in case the svn path
includes spaces, etc) then that escapes the '/' characters...

So I have switched to

StringBuilder escaped = new StringBuilder();

if (path.startsWith("/")) {
  escaped.append("/");
}
boolean first = true;
for (String pathElement: path.split("/")) {
  if (first) {
    escaped.append("/");
    first = false;
  }
  escaped.append(URLEncoder.encode(pathElement), "UTF-8");
}

if (path.endsWith("/") {
  escaped.append("/");
}

return escaped;

So then I worried, what if svn is *crazy* and supports escaping '/' in a
path to support '/' in a pathname... in such a case you might see "\/" and
by splitting at the "/" characters I would break the escaping...

So I try to ask in a more clear way...

"Does Subversion support '/' characters in file names?"

I'm hoping the answer is "no" and I was just worrying for nothing.

-Stephen

P.S. I know that the above code is possibly still a bit too aggresive
w.r.t. encoding strange characters and I may have to write my own URL
encoder anyway to get it "just right"... but I suspect sventon is
correspondingly over-agressive in URL decoding... just not aggressive enough
to handle an escaped "/" character

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2352803

To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
Received on 2009-05-22 10:10:37 CEST

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.