OfficeBean LocalOfficeConnection

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

OfficeBean LocalOfficeConnection

Aidan Butler
Hi All,
 In the OOo Bean, the unique pipe name is being constructed from the
current username. This pipe-name  is then encoded using a URLEncoder
which replaces all spaces in the name with "+" symbols. The encoded URL
is then passed into a "replaceAll" implementation in the same class,
however, the string to be replaced is being passed in as "\\+" instead
of "+". This would be correct if it were a regular expression
replacement, but as it is a plain text replacement, the "+" symbol is
never replaced.

And now to the question :-). Is there a reason that the "+" symbol needs
to be replaced and if so, should it be raised as a bug? The effect I was
seeing was similar to
http://www.openoffice.org/issues/show_bug.cgi?id=25615.

Thanks,
-Aidan


//http://ooo.ximian.com/lxr/source/api/bean/com/sun/star/comp/beans/LocalOfficeConnection.java

707     /* replaces each substring aSearch in aString by aReplace.
708    
709         StringBuffer.replaceAll() is not avaialable in Java 1.3.x.
710      */
711     private static String replaceAll(String aString, String aSearch, String aReplace )
712     {
713         StringBuffer aBuffer = new StringBuffer(aString);
714
715         int nPos = aString.length();
716         int nOfs = aSearch.length();
717        
718         while ( ( nPos = aString.lastIndexOf( aSearch, nPos - 1 ) ) > -1 )
719             aBuffer.replace( nPos, nPos+nOfs, aReplace );
720
721         return aBuffer.toString();
722     }

727static String getPipeName()
728 {
729         // turn user name into a URL and file system safe name (%
chars will not work)
730         String aPipeName = System.getProperty("user.name") +
OFFICE_ID_SUFFIX;
731         aPipeName = replaceAll( aPipeName, "_", "%B7" );
732         return replaceAll( replaceAll(
java.net.URLEncoder.encode(aPipeName), "\\+", "%20" ), "%", "_" );
733     }

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: OfficeBean LocalOfficeConnection

Joachim Lingner - Sun Germany Software Engineer - ham02 - Hamburg
Aidan Butler wrote:
> Hi All,
> In the OOo Bean, the unique pipe name is being constructed from the
> current username. This pipe-name  is then encoded using a URLEncoder
> which replaces all spaces in the name with "+" symbols. The encoded URL
> is then passed into a "replaceAll" implementation in the same class,
> however, the string to be replaced is being passed in as "\\+" instead
> of "+". This would be correct if it were a regular expression
> replacement, but as it is a plain text replacement, the "+" symbol is
> never replaced.
This is a bug.
>
> And now to the question :-). Is there a reason that the "+" symbol needs
> to be replaced
Yes. The office computes the pipe name by the same algorithm.

I have reopened http://www.openoffice.org/issues/show_bug.cgi?id=25615 .
Thanks for pointing out the issue.

Joachim

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]