MCPcopy Create free account
hub / github.com/NativeScript/android / is_label_valid

Function is_label_valid

test-app/runtime/src/main/cpp/ada/ada.cpp:9017–9542  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9015}
9016
9017bool is_label_valid(const std::u32string_view label) {
9018 if (label.empty()) {
9019 return true;
9020 }
9021
9022 ///////////////
9023 // We have a normalization step which ensures that we are in NFC.
9024 // If we receive punycode, we normalize and check that the normalized
9025 // version matches the original.
9026 // --------------------------------------
9027 // The label must be in Unicode Normalization Form NFC.
9028
9029 // Current URL standard indicatest that CheckHyphens is set to false.
9030 // ---------------------------------------
9031 // If CheckHyphens, the label must not contain a U+002D HYPHEN-MINUS character
9032 // in both the third and fourth positions. If CheckHyphens, the label must
9033 // neither begin nor end with a U+002D HYPHEN-MINUS character.
9034
9035 // This is not necessary because we segment the
9036 // labels by '.'.
9037 // ---------------------------------------
9038 // The label must not contain a U+002E ( . ) FULL STOP.
9039 // if (label.find('.') != std::string_view::npos) return false;
9040
9041 // The label must not begin with a combining mark, that is:
9042 // General_Category=Mark.
9043 constexpr static uint32_t combining[] = {
9044 0x300, 0x301, 0x302, 0x303, 0x304, 0x305, 0x306, 0x307,
9045 0x308, 0x309, 0x30a, 0x30b, 0x30c, 0x30d, 0x30e, 0x30f,
9046 0x310, 0x311, 0x312, 0x313, 0x314, 0x315, 0x316, 0x317,
9047 0x318, 0x319, 0x31a, 0x31b, 0x31c, 0x31d, 0x31e, 0x31f,
9048 0x320, 0x321, 0x322, 0x323, 0x324, 0x325, 0x326, 0x327,
9049 0x328, 0x329, 0x32a, 0x32b, 0x32c, 0x32d, 0x32e, 0x32f,
9050 0x330, 0x331, 0x332, 0x333, 0x334, 0x335, 0x336, 0x337,
9051 0x338, 0x339, 0x33a, 0x33b, 0x33c, 0x33d, 0x33e, 0x33f,
9052 0x340, 0x341, 0x342, 0x343, 0x344, 0x345, 0x346, 0x347,
9053 0x348, 0x349, 0x34a, 0x34b, 0x34c, 0x34d, 0x34e, 0x34f,
9054 0x350, 0x351, 0x352, 0x353, 0x354, 0x355, 0x356, 0x357,
9055 0x358, 0x359, 0x35a, 0x35b, 0x35c, 0x35d, 0x35e, 0x35f,
9056 0x360, 0x361, 0x362, 0x363, 0x364, 0x365, 0x366, 0x367,
9057 0x368, 0x369, 0x36a, 0x36b, 0x36c, 0x36d, 0x36e, 0x36f,
9058 0x483, 0x484, 0x485, 0x486, 0x487, 0x488, 0x489, 0x591,
9059 0x592, 0x593, 0x594, 0x595, 0x596, 0x597, 0x598, 0x599,
9060 0x59a, 0x59b, 0x59c, 0x59d, 0x59e, 0x59f, 0x5a0, 0x5a1,
9061 0x5a2, 0x5a3, 0x5a4, 0x5a5, 0x5a6, 0x5a7, 0x5a8, 0x5a9,
9062 0x5aa, 0x5ab, 0x5ac, 0x5ad, 0x5ae, 0x5af, 0x5b0, 0x5b1,
9063 0x5b2, 0x5b3, 0x5b4, 0x5b5, 0x5b6, 0x5b7, 0x5b8, 0x5b9,
9064 0x5ba, 0x5bb, 0x5bc, 0x5bd, 0x5bf, 0x5c1, 0x5c2, 0x5c4,
9065 0x5c5, 0x5c7, 0x610, 0x611, 0x612, 0x613, 0x614, 0x615,
9066 0x616, 0x617, 0x618, 0x619, 0x61a, 0x64b, 0x64c, 0x64d,
9067 0x64e, 0x64f, 0x650, 0x651, 0x652, 0x653, 0x654, 0x655,
9068 0x656, 0x657, 0x658, 0x659, 0x65a, 0x65b, 0x65c, 0x65d,
9069 0x65e, 0x65f, 0x670, 0x6d6, 0x6d7, 0x6d8, 0x6d9, 0x6da,
9070 0x6db, 0x6dc, 0x6df, 0x6e0, 0x6e1, 0x6e2, 0x6e3, 0x6e4,
9071 0x6e7, 0x6e8, 0x6ea, 0x6eb, 0x6ec, 0x6ed, 0x711, 0x730,
9072 0x731, 0x732, 0x733, 0x734, 0x735, 0x736, 0x737, 0x738,
9073 0x739, 0x73a, 0x73b, 0x73c, 0x73d, 0x73e, 0x73f, 0x740,
9074 0x741, 0x742, 0x743, 0x744, 0x745, 0x746, 0x747, 0x748,

Callers 2

from_ascii_to_asciiFunction · 0.85
to_asciiFunction · 0.85

Calls 10

find_last_not_of_nsmFunction · 0.85
is_rtl_labelFunction · 0.85
find_directionFunction · 0.85
frontMethod · 0.80
beginFunction · 0.50
endFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected