diff options
| author | 2025-08-10 15:05:54 +0200 | |
|---|---|---|
| committer | 2025-08-10 15:05:54 +0200 | |
| commit | 67100809b399b60e58490fa8b1c0a72be75ac820 (patch) | |
| tree | ae6df939bf9fe557a766120bee3363f89b47f961 /vendor/github.com/tdewolff/parse/v2/html/hash.go | |
| parent | [feature + performance] add JSON logging format (#4355) (diff) | |
| download | gotosocial-67100809b399b60e58490fa8b1c0a72be75ac820.tar.xz | |
[chore] update dependencies (#4361)
- codeberg.org/gruf/go-kv/v2 v2.0.5 => v2.0.6
- github.com/coreos/go-oidc/v3 v3.14.1 => v3.15.0
- github.com/miekg/dns v1.1.67 => v1.1.68
- github.com/tdewolff/minify/v2 v2.23.9 => v2.23.11
- github.com/yuin/goldmark v1.7.12 => v1.7.13
- golang.org/x/crypto v0.40.0 => v0.41.0
- golang.org/x/image v0.29.0 => v0.30.0
- golang.org/x/net v0.42.0 => v0.43.0
- golang.org/x/sys v0.34.0 => v0.35.0
- golang.org/x/text v0.27.0 => v0.28.0
- modernc.org/sqlite v1.38.0 => v1.38.2
Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4361
Co-authored-by: kim <grufwub@gmail.com>
Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/github.com/tdewolff/parse/v2/html/hash.go')
| -rw-r--r-- | vendor/github.com/tdewolff/parse/v2/html/hash.go | 64 |
1 files changed, 43 insertions, 21 deletions
diff --git a/vendor/github.com/tdewolff/parse/v2/html/hash.go b/vendor/github.com/tdewolff/parse/v2/html/hash.go index 16432ade1..e54bd8fe4 100644 --- a/vendor/github.com/tdewolff/parse/v2/html/hash.go +++ b/vendor/github.com/tdewolff/parse/v2/html/hash.go @@ -1,42 +1,61 @@ package html -// generated by hasher -type=Hash -file=hash.go; DO NOT EDIT, except for adding more constants to the list and rerun go generate - // uses github.com/tdewolff/hasher //go:generate hasher -type=Hash -file=hash.go // Hash defines perfect hashes for a predefined list of strings type Hash uint32 -// Unique hash definitions to be used instead of strings +// Identifiers for the hashes associated with the text in the comments. const ( Iframe Hash = 0x6 // iframe Math Hash = 0x604 // math - Plaintext Hash = 0x1e09 // plaintext + Plaintext Hash = 0x2109 // plaintext Script Hash = 0xa06 // script Style Hash = 0x1405 // style Svg Hash = 0x1903 // svg - Textarea Hash = 0x2308 // textarea + Textarea Hash = 0x2608 // textarea Title Hash = 0xf05 // title - Xmp Hash = 0x1c03 // xmp + Xml Hash = 0x1c03 // xml + Xmp Hash = 0x1f03 // xmp ) -// String returns the hash' name. +//var HashMap = map[string]Hash{ +// "iframe": Iframe, +// "math": Math, +// "plaintext": Plaintext, +// "script": Script, +// "style": Style, +// "svg": Svg, +// "textarea": Textarea, +// "title": Title, +// "xml": Xml, +// "xmp": Xmp, +//} + +// String returns the text associated with the hash. func (i Hash) String() string { + return string(i.Bytes()) +} + +// Bytes returns the text associated with the hash. +func (i Hash) Bytes() []byte { start := uint32(i >> 8) n := uint32(i & 0xff) if start+n > uint32(len(_Hash_text)) { - return "" + return []byte{} } return _Hash_text[start : start+n] } -// ToHash returns the hash whose name is s. It returns zero if there is no -// such hash. It is case sensitive. +// ToHash returns a hash Hash for a given []byte. Hash is a uint32 that is associated with the text in []byte. It returns zero if no match found. func ToHash(s []byte) Hash { if len(s) == 0 || len(s) > _Hash_maxLen { return 0 } + //if 3 < len(s) { + // return HashMap[string(s)] + //} h := uint32(_Hash_hash0) for i := 0; i < len(s); i++ { h ^= uint32(s[i]) @@ -64,18 +83,21 @@ NEXT: return 0 } -const _Hash_hash0 = 0x9acb0442 +const _Hash_hash0 = 0xb4b790b3 const _Hash_maxLen = 9 -const _Hash_text = "iframemathscriptitlestylesvgxmplaintextarea" + +var _Hash_text = []byte("" + + "iframemathscriptitlestylesvgxmlxmplaintextarea") var _Hash_table = [1 << 4]Hash{ - 0x0: 0x2308, // textarea - 0x2: 0x6, // iframe - 0x4: 0xf05, // title - 0x5: 0x1e09, // plaintext - 0x7: 0x1405, // style - 0x8: 0x604, // math - 0x9: 0xa06, // script - 0xa: 0x1903, // svg - 0xb: 0x1c03, // xmp + 0x2: 0xa06, // script + 0x3: 0xf05, // title + 0x4: 0x1405, // style + 0x5: 0x604, // math + 0x6: 0x6, // iframe + 0x8: 0x1c03, // xml + 0x9: 0x2608, // textarea + 0xc: 0x1f03, // xmp + 0xe: 0x2109, // plaintext + 0xf: 0x1903, // svg } |
