summaryrefslogtreecommitdiff
path: root/ucb/source/ucp/inc
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2007-07-18 06:48:38 +0000
committerOliver Bolte <obo@openoffice.org>2007-07-18 06:48:38 +0000
commit50acc0964e617442bea00ba50f92ae958ae19b33 (patch)
tree0125c499c012652ed073316a93bb55e014d6103e /ucb/source/ucp/inc
parentcd9461239d170cf5d5db2af8a87b375c7679048e (diff)
INTEGRATION: CWS calc42 (1.3.14); FILE MERGED
2007/07/12 15:22:13 kso 1.3.14.1: #i79439# - Fixed escaping of whole URIs, adapted to changed ne_uri behavior.
Diffstat (limited to 'ucb/source/ucp/inc')
-rw-r--r--ucb/source/ucp/inc/urihelper.hxx55
1 files changed, 51 insertions, 4 deletions
diff --git a/ucb/source/ucp/inc/urihelper.hxx b/ucb/source/ucp/inc/urihelper.hxx
index bcf20966ae2e..093edf8e6726 100644
--- a/ucb/source/ucp/inc/urihelper.hxx
+++ b/ucb/source/ucp/inc/urihelper.hxx
@@ -4,9 +4,9 @@
*
* $RCSfile: urihelper.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: ihi $ $Date: 2007-06-05 18:08:04 $
+ * last change: $Author: obo $ $Date: 2007-07-18 07:48:38 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -61,13 +61,48 @@ namespace ucb_impl { namespace urihelper {
inline ::rtl::OUString encodeURI( const ::rtl::OUString & rURI )
{
- rtl::OUStringBuffer aResult;
+ rtl::OUString aFragment;
+ rtl::OUString aParams;
+ rtl::OUString aURI;
+
+ sal_Int32 nFragment = rURI.lastIndexOf( sal_Unicode( '#' ) );
+ if ( nFragment != -1 )
+ aFragment = rURI.copy( nFragment + 1 );
+
+ sal_Int32 nParams = ( nFragment == -1 )
+ ? rURI.lastIndexOf( sal_Unicode( '?' ) )
+ : rURI.lastIndexOf( sal_Unicode( '?' ), nFragment );
+ if ( nParams != -1 )
+ aParams = ( nFragment == -1 )
+ ? rURI.copy( nParams + 1 )
+ : rURI.copy( nParams + 1, nFragment - nParams - 1 );
+
+ aURI = ( nParams != -1 )
+ ? rURI.copy( 0, nParams )
+ : ( nFragment != -1 )
+ ? rURI.copy( 0, nFragment )
+ : rURI;
+
+ if ( aFragment.getLength() > 1 )
+ aFragment =
+ rtl::Uri::encode( aFragment,
+ rtl_UriCharClassUric,
+ rtl_UriEncodeCheckEscapes,
+ RTL_TEXTENCODING_UTF8 );
+
+ if ( aParams.getLength() > 1 )
+ aParams =
+ rtl::Uri::encode( aParams,
+ rtl_UriCharClassUric,
+ rtl_UriEncodeCheckEscapes,
+ RTL_TEXTENCODING_UTF8 );
+ rtl::OUStringBuffer aResult;
sal_Int32 nIndex = 0;
do
{
aResult.append(
- rtl::Uri::encode( rURI.getToken( 0, '/', nIndex ),
+ rtl::Uri::encode( aURI.getToken( 0, '/', nIndex ),
rtl_UriCharClassPchar,
rtl_UriEncodeCheckEscapes,
RTL_TEXTENCODING_UTF8 ) );
@@ -76,6 +111,18 @@ namespace ucb_impl { namespace urihelper {
}
while ( nIndex >= 0 );
+ if ( aParams.getLength() > 0 )
+ {
+ aResult.append( sal_Unicode( '?' ) );
+ aResult.append( aParams );
+ }
+
+ if ( aFragment.getLength() > 0 )
+ {
+ aResult.append( sal_Unicode( '#' ) );
+ aResult.append( aFragment );
+ }
+
return aResult.makeStringAndClear();
}