[Libreoffice-commits] core.git: 3 commits - comphelper/source connectivity/source include/rtl sal/qa sal/rtl svgio/source xmloff/source

Stephan Bergmann sbergman at redhat.com
Sat Mar 1 10:28:37 PST 2014


 comphelper/source/misc/storagehelper.cxx            |    7 
 connectivity/source/drivers/postgresql/pq_tools.cxx |    6 
 include/rtl/uri.h                                   |   32 --
 sal/qa/rtl/uri/rtl_testuri.cxx                      |   72 ++---
 sal/rtl/uri.cxx                                     |  257 +++++++++-----------
 svgio/source/svgreader/svgimagenode.cxx             |    6 
 xmloff/source/draw/shapeexport.cxx                  |   10 
 7 files changed, 169 insertions(+), 221 deletions(-)

New commits:
commit d739b01b9f20b1a7fd4b313b28e4dd4e5edd9193
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Sat Mar 1 19:25:38 2014 +0100

    Adapt rtl_uriConvertRelToAbs to RFC 3986
    
    ...which updates RFC 2396, removes the requirement that the base URI's path
    starts with a slash, and clarifies how to treat excess "." and ".." segments.
    
    This nicely allows handling of those odd vnd.sun.star.Package URLs as intended
    now, so that making <foo> absolute relative to base URL
    <vnd.sun.star.Package:Pictures/bar> yields <vnd.sun.star.Package:Pictures/foo>
    instead of provoking a MalformedUriException.
    
    Change-Id: Ice84303a57698a2c05d3a45541fe78b67450fa3c

diff --git a/include/rtl/uri.h b/include/rtl/uri.h
index a4e1d37..248a0d4 100644
--- a/include/rtl/uri.h
+++ b/include/rtl/uri.h
@@ -294,39 +294,27 @@ SAL_DLLPUBLIC void SAL_CALL rtl_uriDecode(
                             rtl_uString ** pResult)
     SAL_THROW_EXTERN_C();
 
-/** Convert a relative URI reference into an absolute one.
+/** Convert a relative URI reference into an absolute URI.
 
-    A URI reference is a URI plus an optional @<"#" fragment> part.
-
-    This function uses the algorithm described in RFC 2396, section 5.2, with
-    the following clarifications:  (1) Backwards-compatible relative URIs
-    starting with a scheme component (see RFC 2396, section 5.2, step 3) are not
-    supported.  (2) Segments "." and ".." within the path of the base URI are
-    not considered special, RFC 2396 seems a bit unlcear about that point.
-    (3) Erroneous excess segments ".." within the path of the relative URI (if
-    it is indeed relative) are left intact, as the examples in RFC 2396,
-    section C.2, suggest.  (4) If the relative URI is a reference to the
-    "current document," the "current document" is taken to be the base URI.
+    This function uses the strict parser algorithm described in RFC 3986,
+    section 5.2.
 
     This function signals exceptions by returning false and letting pException
     point to a message explaining the exception.
 
     @param pBaseUriRef
-    An absolute, hierarchical URI reference that serves as the base URI.  If it
-    has to be inspected (i.e., pRelUriRef is not an absolute URI already), and
-    if it either is not an absolute URI (i.e., does not begin with a
-    @<scheme ":"> part) or has a path that is non-empty but does not start
-    with "/", an exception will be signaled.
+    An absolute URI that serves as the base URI.  If it has to be inspected
+    (i.e., pRelUriRef is not an absolute URI already), and it is not an absolute
+    URI (i.e., does not begin with a @<scheme ":"> part), an exception will be
+    signaled.
 
     @param pRelUriRef
     An URI reference that may be either absolute or relative.  If it is
-    absolute, it will be returned unmodified (and it need not be hierarchical
-    then).
+    absolute, it will be returned unmodified.
 
     @param pResult
-    Returns an absolute URI reference.  Must itself not be null, and must point
-    to either null or a valid string.  If an exception is signalled, it is left
-    unchanged.
+    Returns an absolute URI.  Must itself not be null, and must point to either
+    null or a valid string.  If an exception is signalled, it is left unchanged.
 
     @param pException
     Returns an explanatory message in case an exception is signalled.  Must
diff --git a/sal/qa/rtl/uri/rtl_testuri.cxx b/sal/qa/rtl/uri/rtl_testuri.cxx
index b230d43..fce4aa5 100644
--- a/sal/qa/rtl/uri/rtl_testuri.cxx
+++ b/sal/qa/rtl/uri/rtl_testuri.cxx
@@ -279,14 +279,14 @@ void Test::test_Uri() {
         char const * pAbs;
     };
     static RelToAbsTest const aRelToAbsTest[]
-        = { // The following tests are taken from RFC 2396:
+        = { // The following tests are taken from RFC 3986:
             { "http://a/b/c/d;p?q", "g:h", "g:h" },
             { "http://a/b/c/d;p?q", "g", "http://a/b/c/g" },
             { "http://a/b/c/d;p?q", "./g", "http://a/b/c/g" },
             { "http://a/b/c/d;p?q", "g/", "http://a/b/c/g/" },
             { "http://a/b/c/d;p?q", "/g", "http://a/g" },
             { "http://a/b/c/d;p?q", "//g", "http://g" },
-            { "http://a/b/c/d;p?q", "?y", "http://a/b/c/?y" },
+            { "http://a/b/c/d;p?q", "?y", "http://a/b/c/d;p?y" },
             { "http://a/b/c/d;p?q", "g?y", "http://a/b/c/g?y" },
             { "http://a/b/c/d;p?q", "#s", "http://a/b/c/d;p?q#s" },
             { "http://a/b/c/d;p?q", "g#s", "http://a/b/c/g#s" },
@@ -294,6 +294,7 @@ void Test::test_Uri() {
             { "http://a/b/c/d;p?q", ";x", "http://a/b/c/;x" },
             { "http://a/b/c/d;p?q", "g;x", "http://a/b/c/g;x" },
             { "http://a/b/c/d;p?q", "g;x?y#s", "http://a/b/c/g;x?y#s" },
+            { "http://a/b/c/d;p?q", "", "http://a/b/c/d;p?q" },
             { "http://a/b/c/d;p?q", ".", "http://a/b/c/" },
             { "http://a/b/c/d;p?q", "./", "http://a/b/c/" },
             { "http://a/b/c/d;p?q", "..", "http://a/b/" },
@@ -302,11 +303,10 @@ void Test::test_Uri() {
             { "http://a/b/c/d;p?q", "../..", "http://a/" },
             { "http://a/b/c/d;p?q", "../../", "http://a/" },
             { "http://a/b/c/d;p?q", "../../g", "http://a/g" },
-            { "http://a/b/c/d;p?q", "", "http://a/b/c/d;p?q" },
-            { "http://a/b/c/d;p?q", "../../../g", "http://a/../g" },
-            { "http://a/b/c/d;p?q", "../../../../g", "http://a/../../g" },
-            { "http://a/b/c/d;p?q", "/./g", "http://a/./g" },
-            { "http://a/b/c/d;p?q", "/../g", "http://a/../g" },
+            { "http://a/b/c/d;p?q", "../../../g", "http://a/g" },
+            { "http://a/b/c/d;p?q", "../../../../g", "http://a/g" },
+            { "http://a/b/c/d;p?q", "/./g", "http://a/g" },
+            { "http://a/b/c/d;p?q", "/../g", "http://a/g" },
             { "http://a/b/c/d;p?q", "g.", "http://a/b/c/g." },
             { "http://a/b/c/d;p?q", ".g", "http://a/b/c/.g" },
             { "http://a/b/c/d;p?q", "g..", "http://a/b/c/g.." },
@@ -322,13 +322,15 @@ void Test::test_Uri() {
             { "http://a/b/c/d;p?q", "g#s/./x", "http://a/b/c/g#s/./x" },
             { "http://a/b/c/d;p?q", "g#s/../x", "http://a/b/c/g#s/../x" },
             { "http://a/b/c/d;p?q", "http:g", "http:g" },
+
             { "http!://a/b/c/d;p?q", "g:h", "g:h" },
             { "http!://a/b/c/d;p?q", "g", 0 },
             { "http:b/c/d;p?q", "g:h", "g:h" },
-            { "http:b/c/d;p?q", "g", 0 },
-            { "http://a/b/../", "../c", "http://a/b/../../c" },
+            { "http:b/c/d;p?q", "g", "http:b/c/g" },
+            { "http://a/b/../", "../c", "http://a/c" },
             { "http://a/b/..", "../c", "http://a/c" },
-            { "http://a/./b/", ".././.././../c", "http://a/./../../c" } };
+            { "http://a/./b/", ".././.././../c", "http://a/c" },
+            { "http://a", "b", "http://a/b" } };
     for (std::size_t i = 0; i < sizeof aRelToAbsTest / sizeof (RelToAbsTest); ++i)
     {
         rtl::OUString aAbs;
diff --git a/sal/rtl/uri.cxx b/sal/rtl/uri.cxx
index 774c5f7..2d6c522 100644
--- a/sal/rtl/uri.cxx
+++ b/sal/rtl/uri.cxx
@@ -32,6 +32,7 @@
 #include "sal/types.h"
 #include "sal/macros.h"
 
+#include <algorithm>
 #include <cstddef>
 
 namespace {
@@ -412,81 +413,55 @@ void parseUriRef(rtl_uString const * pUriRef, Components * pComponents)
     }
 }
 
-rtl::OUString joinPaths(Component const & rBasePath, Component const & rRelPath)
+void appendPath(
+    rtl::OUStringBuffer & buffer, sal_Int32 bufferStart, bool precedingSlash,
+    sal_Unicode const * pathBegin, sal_Unicode const * pathEnd)
 {
-    assert(rBasePath.isPresent() && *rBasePath.pBegin == '/');
-    assert(rRelPath.isPresent());
-
-    // The invariant of aBuffer is that it always starts and ends with a slash
-    // (until probably right at the end of the algorithm, when the last segment
-    // of rRelPath is added, which does not necessarily end in a slash):
-    rtl::OUStringBuffer aBuffer(rBasePath.getLength() + rRelPath.getLength());
-        // XXX  numeric overflow
-
-    // Segments "." and ".." within rBasePath are not conisdered special (but
-    // are also not removed by ".." segments within rRelPath), RFC 2396 seems a
-    // bit unclear about this point:
-    sal_Int32 nFixed = 1;
-    sal_Unicode const * p = rBasePath.pBegin + 1;
-    for (sal_Unicode const * q = p; q != rBasePath.pEnd; ++q)
-        if (*q == '/')
-        {
-            if (
-                (q - p == 1 && p[0] == '.') ||
-                (q - p == 2 && p[0] == '.' && p[1] == '.')
-               )
-            {
-                nFixed = q + 1 - rBasePath.pBegin;
-            }
-            p = q + 1;
+    while (precedingSlash || pathBegin != pathEnd) {
+        sal_Unicode const * p = pathBegin;
+        while (p != pathEnd && *p != '/') {
+            ++p;
         }
-    aBuffer.append(rBasePath.pBegin, p - rBasePath.pBegin);
-
-    p = rRelPath.pBegin;
-    if (p != rRelPath.pEnd)
-        for (;;)
-        {
-            sal_Unicode const * q = p;
-            sal_Unicode const * r;
-            for (;;)
-            {
-                if (q == rRelPath.pEnd)
-                {
-                    r = q;
-                    break;
-                }
-                if (*q == '/')
-                {
-                    r = q + 1;
-                    break;
-                }
-                ++q;
+        std::size_t n = p - pathBegin;
+        if (n == 1 && pathBegin[0] == '.') {
+            // input begins with "." -> remove from input (and done):
+            //  i.e., !precedingSlash -> !precedingSlash
+            // input begins with "./" -> remove from input:
+            //  i.e., !precedingSlash -> !precedingSlash
+            // input begins with "/." -> replace with "/" in input (and not yet
+            // done):
+            //  i.e., precedingSlash -> precedingSlash
+            // input begins with "/./" -> replace with "/" in input:
+            //  i.e., precedingSlash -> precedingSlash
+        } else if (n == 2 && pathBegin[0] == '.' && pathBegin[1] == '.') {
+            // input begins with ".." -> remove from input (and done):
+            //  i.e., !precedingSlash -> !precedingSlash
+            // input begins with "../" -> remove from input
+            //  i.e., !precedingSlash -> !precedingSlash
+            // input begins with "/.." -> replace with "/" in input, and shrink
+            // output (not not yet done):
+            //  i.e., precedingSlash -> precedingSlash
+            // input begins with "/../" -> replace with "/" in input, and shrink
+            // output:
+            //  i.e., precedingSlash -> precedingSlash
+            if (precedingSlash) {
+                buffer.truncate(
+                    bufferStart
+                    + std::max<sal_Int32>(
+                        rtl_ustr_lastIndexOfChar_WithLength(
+                            buffer.getStr() + bufferStart,
+                            buffer.getLength() - bufferStart, '/'),
+                        0));
             }
-            if (q - p == 2 && p[0] == '.' && p[1] == '.')
-            {
-                // Erroneous excess segments ".." within rRelPath are left
-                // intact, as the examples in RFC 2396, section C.2, suggest:
-                sal_Int32 i = aBuffer.getLength() - 1;
-                if (i < nFixed)
-                {
-                    aBuffer.append(p, r - p);
-                    nFixed += 3;
-                }
-                else
-                {
-                    while (i > 0 && aBuffer[i - 1] != '/')
-                        --i;
-                    aBuffer.setLength(i);
-                }
+        } else {
+            if (precedingSlash) {
+                buffer.append('/');
             }
-            else if (q - p != 1 || *p != '.')
-                aBuffer.append(p, r - p);
-            if (q == rRelPath.pEnd)
-                break;
-            p = q + 1;
+            buffer.append(pathBegin, n);
+            precedingSlash = p != pathEnd;
         }
-
-    return aBuffer.makeStringAndClear();
+        pathBegin = p + (p == pathEnd ? 0 : 1);
+    }
 }
 
 }
@@ -689,87 +664,101 @@ sal_Bool SAL_CALL rtl_uriConvertRelToAbs(rtl_uString * pBaseUriRef,
                                          rtl_uString ** pException)
     SAL_THROW_EXTERN_C()
 {
-    // If pRelUriRef starts with a scheme component it is an absolute URI
-    // reference, and we are done (i.e., this algorithm does not support
-    // backwards-compatible relative URIs starting with a scheme component, see
-    // RFC 2396, section 5.2, step 3):
+    // Use the strict parser algorithm from RFC 3986, section 5.2, to turn the
+    // relative URI into an absolute one:
+    rtl::OUStringBuffer aBuffer;
     Components aRelComponents;
     parseUriRef(pRelUriRef, &aRelComponents);
     if (aRelComponents.aScheme.isPresent())
     {
-        rtl_uString_assign(pResult, pRelUriRef);
-        return true;
-    }
-
-    // Parse pBaseUriRef; if the scheme component is not present or not valid,
-    // or the path component is not empty and starts with anything but a slash,
-    // an exception is raised:
-    Components aBaseComponents;
-    parseUriRef(pBaseUriRef, &aBaseComponents);
-    if (!aBaseComponents.aScheme.isPresent())
-    {
-        rtl_uString_assign(
-            pException,
-            (rtl::OUString(
-                "<" + rtl::OUString(pBaseUriRef)
-                + "> does not start with a scheme component")
-             .pData));
-        return false;
-    }
-    if (aBaseComponents.aPath.pBegin != aBaseComponents.aPath.pEnd
-        && *aBaseComponents.aPath.pBegin != '/')
-    {
-        rtl_uString_assign(
-            pException,
-            (rtl::OUString(
-                "<" + rtl::OUString(pBaseUriRef)
-                + "> path component does not start with a slash")
-             .pData));
-        return false;
-    }
-
-    // Use the algorithm from RFC 2396, section 5.2, to turn the relative URI
-    // into an absolute one (if the relative URI is a reference to the "current
-    // document," the "current document" is here taken to be the base URI):
-    rtl::OUStringBuffer aBuffer;
-    aBuffer.append(aBaseComponents.aScheme.pBegin,
-                   aBaseComponents.aScheme.getLength());
-    if (aRelComponents.aAuthority.isPresent())
-    {
-        aBuffer.append(aRelComponents.aAuthority.pBegin,
-                       aRelComponents.aAuthority.getLength());
-        aBuffer.append(aRelComponents.aPath.pBegin,
-                       aRelComponents.aPath.getLength());
+        aBuffer.append(aRelComponents.aScheme.pBegin,
+                       aRelComponents.aScheme.getLength());
+        if (aRelComponents.aAuthority.isPresent())
+            aBuffer.append(aRelComponents.aAuthority.pBegin,
+                           aRelComponents.aAuthority.getLength());
+        appendPath(
+            aBuffer, aBuffer.getLength(), false, aRelComponents.aPath.pBegin,
+            aRelComponents.aPath.pEnd);
         if (aRelComponents.aQuery.isPresent())
             aBuffer.append(aRelComponents.aQuery.pBegin,
                            aRelComponents.aQuery.getLength());
     }
     else
     {
-        if (aBaseComponents.aAuthority.isPresent())
-            aBuffer.append(aBaseComponents.aAuthority.pBegin,
-                           aBaseComponents.aAuthority.getLength());
-        if (aRelComponents.aPath.pBegin == aRelComponents.aPath.pEnd
-            && !aRelComponents.aQuery.isPresent())
+        Components aBaseComponents;
+        parseUriRef(pBaseUriRef, &aBaseComponents);
+        if (!aBaseComponents.aScheme.isPresent())
         {
-            aBuffer.append(aBaseComponents.aPath.pBegin,
-                           aBaseComponents.aPath.getLength());
-            if (aBaseComponents.aQuery.isPresent())
-                aBuffer.append(aBaseComponents.aQuery.pBegin,
-                               aBaseComponents.aQuery.getLength());
+            rtl_uString_assign(
+                pException,
+                (rtl::OUString(
+                    "<" + rtl::OUString(pBaseUriRef)
+                    + "> does not start with a scheme component")
+                 .pData));
+            return false;
         }
-        else
+        aBuffer.append(aBaseComponents.aScheme.pBegin,
+                       aBaseComponents.aScheme.getLength());
+        if (aRelComponents.aAuthority.isPresent())
         {
-            if (*aRelComponents.aPath.pBegin == '/')
-                aBuffer.append(aRelComponents.aPath.pBegin,
-                               aRelComponents.aPath.getLength());
-            else
-                aBuffer.append(joinPaths(aBaseComponents.aPath,
-                                         aRelComponents.aPath));
+            aBuffer.append(aRelComponents.aAuthority.pBegin,
+                           aRelComponents.aAuthority.getLength());
+            appendPath(
+                aBuffer, aBuffer.getLength(), false,
+                aRelComponents.aPath.pBegin, aRelComponents.aPath.pEnd);
             if (aRelComponents.aQuery.isPresent())
                 aBuffer.append(aRelComponents.aQuery.pBegin,
                                aRelComponents.aQuery.getLength());
         }
+        else
+        {
+            if (aBaseComponents.aAuthority.isPresent())
+                aBuffer.append(aBaseComponents.aAuthority.pBegin,
+                               aBaseComponents.aAuthority.getLength());
+            if (aRelComponents.aPath.pBegin == aRelComponents.aPath.pEnd)
+            {
+                aBuffer.append(aBaseComponents.aPath.pBegin,
+                               aBaseComponents.aPath.getLength());
+                if (aRelComponents.aQuery.isPresent())
+                    aBuffer.append(aRelComponents.aQuery.pBegin,
+                                   aRelComponents.aQuery.getLength());
+                else if (aBaseComponents.aQuery.isPresent())
+                    aBuffer.append(aBaseComponents.aQuery.pBegin,
+                                   aBaseComponents.aQuery.getLength());
+            }
+            else
+            {
+                if (aRelComponents.aPath.pBegin != aRelComponents.aPath.pEnd
+                    && *aRelComponents.aPath.pBegin == '/')
+                    appendPath(
+                        aBuffer, aBuffer.getLength(), false,
+                        aRelComponents.aPath.pBegin, aRelComponents.aPath.pEnd);
+                else if (aBaseComponents.aAuthority.isPresent()
+                         && aBaseComponents.aPath.pBegin
+                            == aBaseComponents.aPath.pEnd)
+                    appendPath(
+                        aBuffer, aBuffer.getLength(), true,
+                        aRelComponents.aPath.pBegin, aRelComponents.aPath.pEnd);
+                else
+                {
+                    sal_Int32 n = aBuffer.getLength();
+                    sal_Int32 i = rtl_ustr_lastIndexOfChar_WithLength(
+                        aBaseComponents.aPath.pBegin,
+                        aBaseComponents.aPath.getLength(), '/');
+                    if (i >= 0) {
+                        appendPath(
+                            aBuffer, n, false, aBaseComponents.aPath.pBegin,
+                            aBaseComponents.aPath.pBegin + i);
+                    }
+                    appendPath(
+                        aBuffer, n, i >= 0, aRelComponents.aPath.pBegin,
+                        aRelComponents.aPath.pEnd);
+                }
+                if (aRelComponents.aQuery.isPresent())
+                    aBuffer.append(aRelComponents.aQuery.pBegin,
+                                   aRelComponents.aQuery.getLength());
+            }
+        }
     }
     if (aRelComponents.aFragment.isPresent())
         aBuffer.append(aRelComponents.aFragment.pBegin,
diff --git a/svgio/source/svgreader/svgimagenode.cxx b/svgio/source/svgreader/svgimagenode.cxx
index e575502..785136b 100644
--- a/svgio/source/svgreader/svgimagenode.cxx
+++ b/svgio/source/svgreader/svgimagenode.cxx
@@ -238,11 +238,7 @@ namespace svgio
                         try {
                             aAbsUrl = rtl::Uri::convertRelToAbs(rPath, maUrl);
                         } catch (rtl::MalformedUriException & e) {
-                            // Happens for the odd rPath =
-                            // "vnd.sun.star.Package:Pictures/..." scheme using
-                            // path components not starting with a slash by mis-
-                            // design:
-                            SAL_INFO(
+                            SAL_WARN(
                                 "svg",
                                 "caught rtl::MalformedUriException \""
                                     << e.getMessage() << "\"");
commit 58f033569aedbeb2d6bc9d8e903b3f5a63c99614
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Sat Mar 1 19:19:04 2014 +0100

    Fix construction of non-ASCII test string
    
    Change-Id: I495ba4e2394bf0fd09b4d0f0111f9b8531674733

diff --git a/sal/qa/rtl/uri/rtl_testuri.cxx b/sal/qa/rtl/uri/rtl_testuri.cxx
index 63a53b1..b230d43 100644
--- a/sal/qa/rtl/uri/rtl_testuri.cxx
+++ b/sal/qa/rtl/uri/rtl_testuri.cxx
@@ -123,39 +123,23 @@ void Test::test_Uri() {
     }
 
     aText1 = rtl::OUString(
-        RTL_CONSTASCII_USTRINGPARAM(
-            "\x00\x01\x02\x03\x04\x05\x06\x07"
-            "\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"
-            "\x10\x11\x12\x13\x14\x15\x16\x17"
-            "\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"
-            "\x20\x21\x22\x23\x24\x25\x26\x27"
-            "\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F"
-            "\x30\x31\x32\x33\x34\x35\x36\x37"
-            "\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F"
-            "\x40\x41\x42\x43\x44\x45\x46\x47"
-            "\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F"
-            "\x50\x51\x52\x53\x54\x55\x56\x57"
-            "\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F"
-            "\x60\x61\x62\x63\x64\x65\x66\x67"
-            "\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F"
-            "\x70\x71\x72\x73\x74\x75\x76\x77"
-            "\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F"
-            "\x80\x81\x82\x83\x84\x85\x86\x87"
-            "\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F"
-            "\x90\x91\x92\x93\x94\x95\x96\x97"
-            "\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F"
-            "\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7"
-            "\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF"
-            "\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7"
-            "\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF"
-            "\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7"
-            "\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF"
-            "\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7"
-            "\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF"
-            "\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7"
-            "\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF"
-            "\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7"
-            "\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"));
+        ("\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"
+         "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"
+         "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F"
+         "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F"
+         "\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F"
+         "\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F"
+         "\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F"
+         "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F"
+         "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F"
+         "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F"
+         "\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF"
+         "\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF"
+         "\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF"
+         "\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF"
+         "\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF"
+         "\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"),
+        256, RTL_TEXTENCODING_ISO_8859_1);
     aText2 = aText1;
     for (rtl_UriCharClass eCharClass = eFirstCharClass;
          eCharClass <= eLastCharClass;
commit 72111620811bb496004ccbf92ec9ea5c9e9e4ea9
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Sat Mar 1 19:16:40 2014 +0100

    Clean up uses of rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength
    
    Change-Id: Ie37614dac882bfe05f8ce595ae6b20326dce872e

diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx
index 0057cd9..0c60a7c 100644
--- a/comphelper/source/misc/storagehelper.cxx
+++ b/comphelper/source/misc/storagehelper.cxx
@@ -574,12 +574,9 @@ uno::Reference< io::XStream > OStorageHelper::GetStreamAtPackageURL(
         const OUString& rURL, sal_uInt32 const nOpenMode,
         LifecycleProxy & rNastiness)
 {
-    static char const s_PkgScheme[] = "vnd.sun.star.Package:";
-    if (0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
-                rURL.getStr(), rURL.getLength(),
-                s_PkgScheme, SAL_N_ELEMENTS(s_PkgScheme) - 1))
+    OUString path;
+    if (rURL.startsWithIgnoreAsciiCase("vnd.sun.star.Package:", &path))
     {
-        OUString const path(rURL.copy(SAL_N_ELEMENTS(s_PkgScheme)-1));
         return GetStreamAtPath(xParentStorage, path, nOpenMode, rNastiness);
     }
     return 0;
diff --git a/connectivity/source/drivers/postgresql/pq_tools.cxx b/connectivity/source/drivers/postgresql/pq_tools.cxx
index 265c3ae..b7a5411 100644
--- a/connectivity/source/drivers/postgresql/pq_tools.cxx
+++ b/connectivity/source/drivers/postgresql/pq_tools.cxx
@@ -321,13 +321,11 @@ OUString extractTableFromInsert( const OUString & sql )
     int i = 0;
     while (i < sql.getLength() && isWhitespace(sql[i])) { i++; }
 
-    if( 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
-            &sql.getStr()[i], sql.getLength() - i, "insert" , 6 ) )
+    if( sql.matchIgnoreAsciiCase("insert", i) )
     {
         i += 6;
         while (i < sql.getLength() && isWhitespace(sql[i])) { i++; }
-        if( 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
-            &sql.getStr()[i], sql.getLength() - i, "into" , 4 ) )
+        if( sql.matchIgnoreAsciiCase("into", i) )
         {
             i +=4;
             while (i < sql.getLength() && isWhitespace(sql[i])) { i++; }
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index dab81a0..9f119ac 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -3126,16 +3126,13 @@ static void lcl_CopyStream(
     proxy.commitStorages();
 }
 
-static char const s_PkgScheme[] = "vnd.sun.star.Package:";
-
 static OUString
 lcl_StoreMediaAndGetURL(SvXMLExport & rExport,
     uno::Reference<beans::XPropertySet> const& xPropSet,
     OUString const& rURL)
 {
-    if (0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
-                rURL.getStr(), rURL.getLength(),
-                s_PkgScheme, SAL_N_ELEMENTS(s_PkgScheme) - 1))
+    OUString urlPath;
+    if (rURL.startsWithIgnoreAsciiCase("vnd.sun.star.Package:", &urlPath))
     {
         try // video is embedded
         {
@@ -3152,9 +3149,6 @@ lcl_StoreMediaAndGetURL(SvXMLExport & rExport,
                 return OUString();
             }
 
-            OUString const urlPath(
-                    rURL.copy(SAL_N_ELEMENTS(s_PkgScheme)-1));
-
             lcl_CopyStream(xInStream, xTarget, rURL);
 
             return urlPath;


More information about the Libreoffice-commits mailing list