diff options
author | Thaddeus Crews <repiteo@outlook.com> | 2024-10-29 19:25:49 -0500 |
---|---|---|
committer | Thaddeus Crews <repiteo@outlook.com> | 2024-10-29 19:25:49 -0500 |
commit | 49cf7996e16b0e9b7b2b77e94085d18de21ece1b (patch) | |
tree | 07cf2a09367618d1eefb5b2e49b1b600bcaaba44 /thirdparty/icu4c/common/uts46.cpp | |
parent | 05a4620e88fc454e844f69e87a6eb444426c2a6e (diff) | |
parent | e698870caa3dff7234f0a4433b1751834b9e7811 (diff) | |
download | redot-engine-49cf7996e16b0e9b7b2b77e94085d18de21ece1b.tar.gz |
Merge pull request #98496 from bruvzg/icu761
Update ICU to 76.1
Diffstat (limited to 'thirdparty/icu4c/common/uts46.cpp')
-rw-r--r-- | thirdparty/icu4c/common/uts46.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/thirdparty/icu4c/common/uts46.cpp b/thirdparty/icu4c/common/uts46.cpp index f0e1372422..018c0e19b7 100644 --- a/thirdparty/icu4c/common/uts46.cpp +++ b/thirdparty/icu4c/common/uts46.cpp @@ -451,10 +451,10 @@ UTS46::processUTF8(StringPiece src, return; } char c=srcArray[i]; - if((int8_t)c<0) { // (uint8_t)c>0x7f + if (static_cast<int8_t>(c) < 0) { // (uint8_t)c>0x7f break; } - int cData=asciiData[(int)c]; // Cast: gcc warns about indexing with a char. + int cData = asciiData[static_cast<int>(c)]; // Cast: gcc warns about indexing with a char. if(cData>0) { destArray[i]=c+0x20; // Lowercase an uppercase ASCII letter. } else if(cData<0 && disallowNonLDHDot) { @@ -756,7 +756,12 @@ UTS46::processLabel(UnicodeString &dest, if(U_FAILURE(errorCode)) { return labelLength; } - if(!isValid) { + // Unicode 15.1 UTS #46: + // Added an additional condition in 4.1 Validity Criteria to + // disallow labels such as xn--xn---epa., which do not round-trip. + // --> Validity Criteria new criterion 4: + // If not CheckHyphens, the label must not begin with “xn--”. + if(!isValid || fromPunycode.startsWith(UnicodeString::readOnlyAlias(u"xn--"))) { info.labelErrors|=UIDNA_ERROR_INVALID_ACE_LABEL; return markBadACELabel(dest, labelStart, labelLength, toASCII, info, errorCode); } @@ -796,7 +801,7 @@ UTS46::processLabel(UnicodeString &dest, // in a non-Punycode label or U+FFFD itself in a Punycode label. // We also check for dots which can come from the input to a single-label function. // Ok to cast away const because we own the UnicodeString. - char16_t *s=(char16_t *)label; + char16_t* s = const_cast<char16_t*>(label); const char16_t *limit=label+labelLength; char16_t oredChars=0; // If we enforce STD3 rules, then ASCII characters other than LDH and dot are disallowed. @@ -827,7 +832,7 @@ UTS46::processLabel(UnicodeString &dest, U16_NEXT_UNSAFE(label, cpLength, c); if((U_GET_GC_MASK(c)&U_GC_M_MASK)!=0) { info.labelErrors|=UIDNA_ERROR_LEADING_COMBINING_MARK; - labelString->replace(labelStart, cpLength, (char16_t)0xfffd); + labelString->replace(labelStart, cpLength, static_cast<char16_t>(0xfffd)); label=labelString->getBuffer()+labelStart; labelLength+=1-cpLength; if(labelString==&dest) { @@ -947,7 +952,7 @@ UTS46::markBadACELabel(UnicodeString &dest, } } if(onlyLDH) { - dest.insert(labelStart+labelLength, (char16_t)0xfffd); + dest.insert(labelStart + labelLength, static_cast<char16_t>(0xfffd)); if(dest.isBogus()) { errorCode=U_MEMORY_ALLOCATION_ERROR; return 0; @@ -1361,7 +1366,7 @@ uidna_labelToASCII(const UIDNA *idna, if(!checkArgs(label, length, dest, capacity, pInfo, pErrorCode)) { return 0; } - UnicodeString src((UBool)(length<0), label, length); + UnicodeString src(length < 0, label, length); UnicodeString destString(dest, 0, capacity); IDNAInfo info; reinterpret_cast<const IDNA *>(idna)->labelToASCII(src, destString, info, *pErrorCode); @@ -1377,7 +1382,7 @@ uidna_labelToUnicode(const UIDNA *idna, if(!checkArgs(label, length, dest, capacity, pInfo, pErrorCode)) { return 0; } - UnicodeString src((UBool)(length<0), label, length); + UnicodeString src(length < 0, label, length); UnicodeString destString(dest, 0, capacity); IDNAInfo info; reinterpret_cast<const IDNA *>(idna)->labelToUnicode(src, destString, info, *pErrorCode); @@ -1393,7 +1398,7 @@ uidna_nameToASCII(const UIDNA *idna, if(!checkArgs(name, length, dest, capacity, pInfo, pErrorCode)) { return 0; } - UnicodeString src((UBool)(length<0), name, length); + UnicodeString src(length < 0, name, length); UnicodeString destString(dest, 0, capacity); IDNAInfo info; reinterpret_cast<const IDNA *>(idna)->nameToASCII(src, destString, info, *pErrorCode); @@ -1409,7 +1414,7 @@ uidna_nameToUnicode(const UIDNA *idna, if(!checkArgs(name, length, dest, capacity, pInfo, pErrorCode)) { return 0; } - UnicodeString src((UBool)(length<0), name, length); + UnicodeString src(length < 0, name, length); UnicodeString destString(dest, 0, capacity); IDNAInfo info; reinterpret_cast<const IDNA *>(idna)->nameToUnicode(src, destString, info, *pErrorCode); |