[prev in list] [next in list] [prev in thread] [next in thread]
List: subclipse-users
Subject: Re: [Subclipse-users] Can't create folder with square brackets
From: Mark Phippard <markphip () gmail ! com>
Date: 2014-10-24 13:07:41
Message-ID: CAHFaGCoJi1kgZ8Udd+Ra+5aehJhzpKNFrEkdsFBSypaCXwYXDQ () mail ! gmail ! com
[Download RAW message or body]
We tried techniques like those once but they are encoding the URL the way a
browser form POST wants to do it, not the way Subversion expects it. I
will try to find the RFC that Subversion is following and see if I can find
something better, but we have done this in the past. We obviously would
prefer to call a method someone else wrote that does this correctly.
On Fri, Oct 24, 2014 at 8:02 AM, David Balažic <david.balazic@comtrade.com>
wrote:
> Maybe some of the possibilities mentioned here:
> http://stackoverflow.com/a/16226168/822870
>
>
>
> David Balažic
>
> Software Engineer
>
> www.comtrade.com
>
>
>
> *From:* Mark Phippard [mailto:markphip@gmail.com]
> *Sent:* 24. October 2014 13:12
>
> *To:* users@subclipse.tigris.org
> *Subject:* Re: [Subclipse-users] Can't create folder with square brackets
> *Importance:* Low
>
>
>
> Is it not pretty clear already that is what we have tried to do? Find one
> better and let us know.
>
>
> On Oct 24, 2014, at 7:05 AM, David Balažic <david.balazic@comtrade.com>
> wrote:
>
> Yes, there it reproduces for me too. (trying to create a folder in the
> »SVN Repository Exploring « perspective)
>
>
>
> I updated to subclipse 1.10.6 and now the characters [ and ] work, but
> others still don't, like # or %.
>
>
>
> I suggest using an existing encoding method instead of reinventing the
> wheel, because »home made « solutions are always full of problems like these.
>
>
>
> Regards,
>
> David Balažic
>
> Software Engineer
>
> www.comtrade.com
>
>
>
> *From:* Stephen Elsemore [mailto:selsemore@collab.net
> <selsemore@collab.net>]
> *Sent:* 23. October 2014 16:07
> *To:* users@subclipse.tigris.org
> *Subject:* Re: [Subclipse-users] Can't create folder with square brackets
> *Importance:* Low
>
>
>
> I was able to reproduce the problem by right clicking a folder in the SVN
> Repositories view, selecting New -> New remote folder, and then trying to
> add a folder with square brackets in the name. I got:
>
> org.apache.subversion.javahl.ClientException: Bogus URL svn: URL
> 'myurlwithbrackets' is not properly URI-encoded
>
> I got similar errors if I tried to show history for a folder or file with
> square brackets in the name.
>
>
>
> On Thu, Oct 23, 2014 at 4:01 PM, Mark Phippard <markphip@gmail.com> wrote:
>
> On Thu, Oct 23, 2014 at 9:45 AM, David Balažic <david.balazic@comtrade.com>
> wrote:
>
>
>
> I was curious and tried to reproduce the problem, but could not.
>
> I have Eclipse Kepler SR-2 (v4.3.2) with:
>
> Subclipse (Required) 1.10.5
>
> Subversion Client Adapter (Required) 1.10.1
>
> Subversion JavaHL Native Library Adapter 1.8.10
>
>
>
> With repository on VisualSVN Server 3.0.0
>
>
>
> I created , updated, viewed the log of a folder with sqaure brackets in
> its name but everything worked without error.
>
> Does the error happen in some special circumstances?
>
>
>
> Steve fixed this before I ever tried it. Not sure what he did to test
> it. The OP mentions creating a folder. Did you try doing it against the
> remote repository? It is possible you do not see this if you do it locally
> and then just commit the folder.
>
>
>
> In general, when a URL is passed to the SVN API it has to be URI-encoded.
> So, as an example, we have to convert spaces to %20. Any character that
> has to be converted to a %xx value has to be done this way. We handle this
> in the toString() method of our SVNUrl class:
>
>
>
> *public* String toString() {
>
> *// The URI class will throw Exception if there are spaces in the URL, but it seems*
>
> *// to handle other classes OK. I tested with @ + and Unicode characters. It leaves*
>
> *// the @ and + alone and converts Unicode to %nn. It is possible there are other*
>
> *// characters we need to replace here besides space.*
>
> String s = get().replace(" ", "%20").replace("[", "%5B").replace("]","%5D");
>
> *try* {
>
> URI u = *new* URI(s);
>
> *return* u.toASCIIString();
>
> } *catch* (URISyntaxException e) {
>
> *return* s;
>
> }
>
> }
>
>
>
> So most of the work happens in the URI.toASCIIString() method that we
> call. As the comment notes, this method does not convert spaces (and
> possibly other characters). I assume that Steve confirmed that it does not
> convert brackets and so he added those to the manual exceptions. I have
> not checked if that is right or wrong, but that is what is needed here in
> general.
>
>
>
> SVN itself handles all of this fine internally. The only issue is when we
> have to directly provide one of these URL's in an API call.
>
>
> --
> Thanks
>
> Mark Phippard
> http://markphip.blogspot.com/
>
>
>
>
--
Thanks
Mark Phippard
http://markphip.blogspot.com/
------------------------------------------------------
http://subclipse.tigris.org/ds/viewMessage.do?dsForumId=1047&dsMessageId=3090403
To unsubscribe from this discussion, e-mail: [users-unsubscribe@subclipse.tigris.org].
[Attachment #3 (text/html)]
<div dir="ltr">We tried techniques like those once but they are encoding the URL the \
way a browser form POST wants to do it, not the way Subversion expects it. I will \
try to find the RFC that Subversion is following and see if I can find something \
better, but we have done this in the past. We obviously would prefer to call a \
method someone else wrote that does this correctly.</div><div \
class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 24, 2014 at 8:02 AM, \
David Balažic <span dir="ltr"><<a href="mailto:david.balazic@comtrade.com" \
target="_blank">david.balazic@comtrade.com</a>></span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">
<div lang="SL" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Maybe \
some of the possibilities mentioned here: <a \
href="http://stackoverflow.com/a/16226168/822870" \
target="_blank">http://stackoverflow.com/a/16226168/822870</a><u></u><u></u></span></p><span \
class=""> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> \
<u></u></span></p> <div>
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">David \
Balažic<u></u><u></u></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Software \
Engineer<u></u><u></u></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><a \
href="http://www.comtrade.com" \
target="_blank">www.comtrade.com</a><u></u><u></u></span></p> </div>
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> \
<u></u></span></p> </span><div style="border:none;border-left:solid blue \
1.5pt;padding:0cm 0cm 0cm 4.0pt"> <div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" \
style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span \
lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> \
Mark Phippard [mailto:<a href="mailto:markphip@gmail.com" \
target="_blank">markphip@gmail.com</a>] <br>
<b>Sent:</b> 24. October 2014 13:12</span></p><div><div class="h5"><br>
<b>To:</b> <a href="mailto:users@subclipse.tigris.org" \
target="_blank">users@subclipse.tigris.org</a><br> <b>Subject:</b> Re: \
[Subclipse-users] Can't create folder with square brackets<br> <b>Importance:</b> \
Low<u></u><u></u></div></div><p></p> </div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Is it not pretty clear already that is what we have tried to do? \
Find one better and let us know.<u></u><u></u></p> </div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
On Oct 24, 2014, at 7:05 AM, David Balažic <<a \
href="mailto:david.balazic@comtrade.com" \
target="_blank">david.balazic@comtrade.com</a>> wrote:<u></u><u></u></p> </div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Yes, \
there it reproduces for me too. (trying to create a folder in the »SVN Repository \
Exploring « perspective)</span><u></u><u></u></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> \
</span><u></u><u></u></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I \
updated to subclipse 1.10.6 and now the characters [ and ] work, but others still \
don't, like # or %.</span><u></u><u></u></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> \
</span><u></u><u></u></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I \
suggest using an existing encoding method instead of reinventing the wheel, because \
»home made « solutions are always full of problems like \
these.</span><u></u><u></u></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> \
</span><u></u><u></u></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Regards,</span><u></u><u></u></p>
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">David \
Balažic</span><u></u><u></u></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Software \
Engineer</span><u></u><u></u></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><a \
href="http://www.comtrade.com" \
target="_blank">www.comtrade.com</a></span><u></u><u></u></p> <p \
class="MsoNormal"><span \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> \
</span><u></u><u></u></p> <div style="border:none;border-left:solid blue \
1.5pt;padding:0cm 0cm 0cm 4.0pt"> <div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" \
style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span \
lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> \
Stephen Elsemore [<a href="mailto:selsemore@collab.net" \
target="_blank">mailto:selsemore@collab.net</a>] <br>
<b>Sent:</b> 23. October 2014 16:07<br>
<b>To:</b> <a href="mailto:users@subclipse.tigris.org" \
target="_blank">users@subclipse.tigris.org</a><br> <b>Subject:</b> Re: \
[Subclipse-users] Can't create folder with square brackets<br> <b>Importance:</b> \
Low</span><u></u><u></u></p> </div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">I was able to reproduce the problem \
by right clicking a folder in the SVN Repositories view, selecting New -> New \
remote folder, and then trying to add a folder with square brackets in the name. I \
got:<u></u><u></u></p> </div>
<p class="MsoNormal" \
style="margin-bottom:12.0pt">org.apache.subversion.javahl.ClientException: Bogus URL \
svn: URL 'myurlwithbrackets' is not properly URI-encoded<u></u><u></u></p> \
</div> <p class="MsoNormal">I got similar errors if I tried to show history for a \
folder or file with square brackets in the name.<u></u><u></u></p> </div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On Thu, Oct 23, 2014 at 4:01 PM, Mark Phippard <<a \
href="mailto:markphip@gmail.com" target="_blank">markphip@gmail.com</a>> \
wrote:<u></u><u></u></p> <div>
<p class="MsoNormal">On Thu, Oct 23, 2014 at 9:45 AM, David Balažic <<a \
href="mailto:david.balazic@comtrade.com" \
target="_blank">david.balazic@comtrade.com</a>> wrote:<u></u><u></u></p> <div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm \
6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt"> <div>
<div>
<p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I \
was curious and tried to reproduce the problem, but could not. \
</span><u></u><u></u></p> <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I \
have Eclipse Kepler SR-2 (v4.3.2) with:</span><u></u><u></u></p> <p \
class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> \
Subclipse (Required) 1.10.5</span><u></u><u></u></p> <p class="MsoNormal"><span \
lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> \
Subversion Client Adapter (Required) 1.10.1</span><u></u><u></u></p> <p \
class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> \
Subversion JavaHL Native Library Adapter \
1.8.10</span><u></u><u></u></p> <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> \
</span><u></u><u></u></p> <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">With \
repository on VisualSVN Server 3.0.0</span><u></u><u></u></p> <p \
class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> \
</span><u></u><u></u></p> <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I \
created , updated, viewed the log of a folder with sqaure brackets in its name but \
everything worked without error.</span><u></u><u></u></p> <p class="MsoNormal"><span \
lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Does \
the error happen in some special circumstances?</span><u></u><u></u></p> <p \
class="MsoNormal"> <u></u><u></u></p> </div>
</div>
</blockquote>
<div>
<p class="MsoNormal">Steve fixed this before I ever tried it. Not sure what he did \
to test it. The OP mentions creating a folder. Did you try doing it against the \
remote repository? It is possible you do not see this if you do it locally and then \
just commit the folder.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">In general, when a URL is passed to the SVN API it has to be \
URI-encoded. So, as an example, we have to convert spaces to %20. Any character \
that has to be converted to a %xx value has to be done this way. We handle this in \
the toString() method of our SVNUrl class:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<pre style="line-height:12.5pt"><b><span \
style="font-family:Courier;color:#9c20ee">public</span></b><span \
style="font-family:Courier;color:black"> String toString() \
{</span><u></u><u></u></pre> <pre style="line-height:12.5pt"><span \
style="font-family:Courier;color:black"> </span><i><span \
style="font-family:Courier;color:#ac2020">// The URI class will throw Exception if \
there are spaces in the URL, but it seems</span></i><u></u><u></u></pre> <pre \
style="line-height:12.5pt"><span style="font-family:Courier;color:black"> \
</span><i><span style="font-family:Courier;color:#ac2020">// to handle other classes \
OK. I tested with @ + and Unicode characters. It \
leaves</span></i><u></u><u></u></pre> <pre style="line-height:12.5pt"><span \
style="font-family:Courier;color:black"> </span><i><span \
style="font-family:Courier;color:#ac2020">// the @ and + alone and converts Unicode \
to %nn. It is possible there are other</span></i><u></u><u></u></pre> <pre \
style="line-height:12.5pt"><span style="font-family:Courier;color:black"> \
</span><i><span style="font-family:Courier;color:#ac2020">// characters we need to \
replace here besides space.</span></i><u></u><u></u></pre> <pre \
style="line-height:12.5pt"><span style="font-family:Courier;color:black"> \
String s = get().replace(</span><span \
style="font-family:Courier;color:#bd8d8b">" "</span><span \
style="font-family:Courier;color:black">, </span><span \
style="font-family:Courier;color:#bd8d8b">"%20"</span><span \
style="font-family:Courier;color:black">).replace(</span><span \
style="font-family:Courier;color:#bd8d8b">"["</span><span \
style="font-family:Courier;color:black">, </span><span \
style="font-family:Courier;color:#bd8d8b">"%5B"</span><span \
style="font-family:Courier;color:black">).replace(</span><span \
style="font-family:Courier;color:#bd8d8b">"]"</span><span \
style="font-family:Courier;color:black">,</span><span \
style="font-family:Courier;color:#bd8d8b">"%5D"</span><span \
style="font-family:Courier;color:black">);</span><u></u><u></u></pre> <pre \
style="line-height:12.5pt"><span style="font-family:Courier;color:black"> \
</span><b><span style="font-family:Courier;color:#9c20ee">try</span></b><span \
style="font-family:Courier;color:black"> {</span><u></u><u></u></pre> <pre \
style="line-height:12.5pt"><span style="font-family:Courier;color:black"> \
URI u = </span><b><span style="font-family:Courier;color:#9c20ee">new</span></b><span \
style="font-family:Courier;color:black"> URI(s);</span><u></u><u></u></pre> <pre \
style="line-height:12.5pt"><span style="font-family:Courier;color:black"> \
</span><b><span style="font-family:Courier;color:#9c20ee">return</span></b><span \
style="font-family:Courier;color:black"> \
u.toASCIIString();</span><u></u><u></u></pre> <pre style="line-height:12.5pt"><span \
style="font-family:Courier;color:black"> } </span><b><span \
style="font-family:Courier;color:#9c20ee">catch</span></b><span \
style="font-family:Courier;color:black"> (URISyntaxException e) \
{</span><u></u><u></u></pre> <pre style="line-height:12.5pt"><span \
style="font-family:Courier;color:black"> \
</span><b><span style="font-family:Courier;color:#9c20ee">return</span></b><span \
style="font-family:Courier;color:black"> s;</span><u></u><u></u></pre> <pre \
style="line-height:12.5pt"><span style="font-family:Courier;color:black"> \
}</span><u></u><u></u></pre> <pre style="line-height:12.5pt"><span \
style="font-family:Courier;color:black"> }</span><u></u><u></u></pre> </div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">So most of the work happens in the URI.toASCIIString() method \
that we call. As the comment notes, this method does not convert spaces (and \
possibly other characters). I assume that Steve confirmed that it does not convert \
brackets and so he added those to the manual exceptions. I have not checked if \
that is right or wrong, but that is what is needed here in general.<u></u><u></u></p> \
</div> <div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">SVN itself handles all of this fine internally. The only issue \
is when we have to directly provide one of these URL's in an API call. \
<u></u><u></u></p> </div>
</div>
<p class="MsoNormal"><span style="color:#888888"><br>
<span>-- </span><br>
<span>Thanks</span><br>
<br>
<span>Mark Phippard</span><br>
<span><a href="http://markphip.blogspot.com/" \
target="_blank">http://markphip.blogspot.com/</a> </span></span><u></u><u></u></p>
</div>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
</blockquote>
</div></div></div>
</div>
</div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Thanks<br><br>Mark \
Phippard<br><a href="http://markphip.blogspot.com/">http://markphip.blogspot.com/</a> \
</div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic