tools/source/fsys/urlobj.cxx | 91 +++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 54 deletions(-)
New commits: commit 132d652ad1af4ec067fe08e388e8ddba963ddc2b Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Fri Dec 24 21:37:17 2021 +0100 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Fri Dec 24 23:09:14 2021 +0100 Simplify INetURLObject::parseHostOrNetBiosName Change-Id: I18818e89b2e6f0ef203caa51ba554c281753d3f5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127383 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> 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; }