summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-12-24 21:37:17 +0100
committerMike Kaganski <mike.kaganski@collabora.com>2021-12-24 23:09:14 +0100
commit132d652ad1af4ec067fe08e388e8ddba963ddc2b (patch)
treee4e03d3da23cb0bc2013cf1189619df1c77bbbed /tools
parent8b333c76945960fc62a01829666ba234f59a6d94 (diff)
Simplify INetURLObject::parseHostOrNetBiosName
Change-Id: I18818e89b2e6f0ef203caa51ba554c281753d3f5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127383 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/source/fsys/urlobj.cxx91
1 files changed, 37 insertions, 54 deletions
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index 7b86fe0f5261..67cb1f1cd024 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -2831,67 +2831,50 @@ bool INetURLObject::parseHostOrNetBiosName(
EncodeMechanism eMechanism, rtl_TextEncoding eCharset, bool bNetBiosName,
OUStringBuffer* pCanonic)
{
+ if (pBegin >= pEnd)
+ return true;
sal_Int32 nOriginalCanonicLength = pCanonic ? pCanonic->getLength() : 0;
- if (pBegin < pEnd)
+ if (sal_Unicode const* p = pBegin; parseHost(p, pEnd, pCanonic) && p == pEnd)
+ return true;
+ if (pCanonic)
+ pCanonic->setLength(nOriginalCanonicLength); // discard parseHost results
+ if (!bNetBiosName)
+ return false;
+ while (pBegin < pEnd)
{
- sal_Unicode const * p = pBegin;
- if (!parseHost(p, pEnd, pCanonic) || p != pEnd)
+ EscapeType eEscapeType;
+ sal_uInt32 nUTF32 = getUTF32(pBegin, pEnd, eMechanism, eCharset, eEscapeType);
+ switch (nUTF32)
{
- if (bNetBiosName)
- {
- OUStringBuffer buf;
- while (pBegin < pEnd)
- {
- EscapeType eEscapeType;
- sal_uInt32 nUTF32 = getUTF32(pBegin, pEnd,
- eMechanism, eCharset,
- eEscapeType);
- if (!INetMIME::isVisible(nUTF32))
- {
- if (pCanonic)
- pCanonic->setLength(nOriginalCanonicLength);
- return false;
- }
- if (!rtl::isAsciiAlphanumeric(nUTF32))
- switch (nUTF32)
- {
- case '"':
- case '*':
- case '+':
- case ',':
- case '/':
- case ':':
- case ';':
- case '<':
- case '=':
- case '>':
- case '?':
- case '[':
- case '\\':
- case ']':
- case '`':
- case '|':
- return false;
- }
- if (pCanonic != nullptr) {
- appendUCS4(
- buf, nUTF32, eEscapeType, PART_URIC,
- eCharset, true);
- }
- }
- if (pCanonic)
- {
- pCanonic->setLength(nOriginalCanonicLength);
- pCanonic->append(buf);
- }
- }
- else
- {
+ case '"':
+ case '*':
+ case '+':
+ case ',':
+ case '/':
+ case ':':
+ case ';':
+ case '<':
+ case '=':
+ case '>':
+ case '?':
+ case '[':
+ case '\\':
+ case ']':
+ case '`':
+ case '|':
if (pCanonic)
pCanonic->setLength(nOriginalCanonicLength);
return false;
- }
+ default:
+ if (!INetMIME::isVisible(nUTF32))
+ {
+ if (pCanonic)
+ pCanonic->setLength(nOriginalCanonicLength);
+ return false;
+ }
}
+ if (pCanonic)
+ appendUCS4(*pCanonic, nUTF32, eEscapeType, PART_URIC, eCharset, true);
}
return true;
}