influxdb/query/promql/unicode.go

216 lines
8.9 KiB
Go

package promql
import (
"errors"
"strconv"
)
// validateUnicodeEscape checks that the provided escape sequence is a
// valid Unicode escape sequence.
func validateUnicodeEscape(escape, errMsg string) (interface{}, error) {
r, _, _, err := strconv.UnquoteChar("\\"+escape, '"')
if err != nil {
return nil, errors.New(errMsg)
}
if 0xD800 <= r && r <= 0xDFFF {
return nil, errors.New(errMsg)
}
return nil, nil
}
var unicodeClasses = map[string]bool{
"ASCII_Hex_Digit": true,
"Arabic": true,
"Armenian": true,
"Avestan": true,
"Balinese": true,
"Bamum": true,
"Bassa_Vah": true,
"Batak": true,
"Bengali": true,
"Bidi_Control": true,
"Bopomofo": true,
"Brahmi": true,
"Braille": true,
"Buginese": true,
"Buhid": true,
"C": true,
"Canadian_Aboriginal": true,
"Carian": true,
"Caucasian_Albanian": true,
"Cc": true,
"Cf": true,
"Chakma": true,
"Cham": true,
"Cherokee": true,
"Co": true,
"Common": true,
"Coptic": true,
"Cs": true,
"Cuneiform": true,
"Cypriot": true,
"Cyrillic": true,
"Dash": true,
"Deprecated": true,
"Deseret": true,
"Devanagari": true,
"Diacritic": true,
"Duployan": true,
"Egyptian_Hieroglyphs": true,
"Elbasan": true,
"Ethiopic": true,
"Extender": true,
"Georgian": true,
"Glagolitic": true,
"Gothic": true,
"Grantha": true,
"Greek": true,
"Gujarati": true,
"Gurmukhi": true,
"Han": true,
"Hangul": true,
"Hanunoo": true,
"Hebrew": true,
"Hex_Digit": true,
"Hiragana": true,
"Hyphen": true,
"IDS_Binary_Operator": true,
"IDS_Trinary_Operator": true,
"Ideographic": true,
"Imperial_Aramaic": true,
"Inherited": true,
"Inscriptional_Pahlavi": true,
"Inscriptional_Parthian": true,
"Javanese": true,
"Join_Control": true,
"Kaithi": true,
"Kannada": true,
"Katakana": true,
"Kayah_Li": true,
"Kharoshthi": true,
"Khmer": true,
"Khojki": true,
"Khudawadi": true,
"L": true,
"Lao": true,
"Latin": true,
"Lepcha": true,
"Limbu": true,
"Linear_A": true,
"Linear_B": true,
"Lisu": true,
"Ll": true,
"Lm": true,
"Lo": true,
"Logical_Order_Exception": true,
"Lt": true,
"Lu": true,
"Lycian": true,
"Lydian": true,
"M": true,
"Mahajani": true,
"Malayalam": true,
"Mandaic": true,
"Manichaean": true,
"Mc": true,
"Me": true,
"Meetei_Mayek": true,
"Mende_Kikakui": true,
"Meroitic_Cursive": true,
"Meroitic_Hieroglyphs": true,
"Miao": true,
"Mn": true,
"Modi": true,
"Mongolian": true,
"Mro": true,
"Myanmar": true,
"N": true,
"Nabataean": true,
"Nd": true,
"New_Tai_Lue": true,
"Nko": true,
"Nl": true,
"No": true,
"Noncharacter_Code_Point": true,
"Ogham": true,
"Ol_Chiki": true,
"Old_Italic": true,
"Old_North_Arabian": true,
"Old_Permic": true,
"Old_Persian": true,
"Old_South_Arabian": true,
"Old_Turkic": true,
"Oriya": true,
"Osmanya": true,
"Other_Alphabetic": true,
"Other_Default_Ignorable_Code_Point": true,
"Other_Grapheme_Extend": true,
"Other_ID_Continue": true,
"Other_ID_Start": true,
"Other_Lowercase": true,
"Other_Math": true,
"Other_Uppercase": true,
"P": true,
"Pahawh_Hmong": true,
"Palmyrene": true,
"Pattern_Syntax": true,
"Pattern_White_Space": true,
"Pau_Cin_Hau": true,
"Pc": true,
"Pd": true,
"Pe": true,
"Pf": true,
"Phags_Pa": true,
"Phoenician": true,
"Pi": true,
"Po": true,
"Ps": true,
"Psalter_Pahlavi": true,
"Quotation_Mark": true,
"Radical": true,
"Rejang": true,
"Runic": true,
"S": true,
"STerm": true,
"Samaritan": true,
"Saurashtra": true,
"Sc": true,
"Sharada": true,
"Shavian": true,
"Siddham": true,
"Sinhala": true,
"Sk": true,
"Sm": true,
"So": true,
"Soft_Dotted": true,
"Sora_Sompeng": true,
"Sundanese": true,
"Syloti_Nagri": true,
"Syriac": true,
"Tagalog": true,
"Tagbanwa": true,
"Tai_Le": true,
"Tai_Tham": true,
"Tai_Viet": true,
"Takri": true,
"Tamil": true,
"Telugu": true,
"Terminal_Punctuation": true,
"Thaana": true,
"Thai": true,
"Tibetan": true,
"Tifinagh": true,
"Tirhuta": true,
"Ugaritic": true,
"Unified_Ideograph": true,
"Vai": true,
"Variation_Selector": true,
"Warang_Citi": true,
"White_Space": true,
"Yi": true,
"Z": true,
"Zl": true,
"Zp": true,
"Zs": true,
}