gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

lex.go (1505B)


      1 // This file contains code adapted from the Go standard library
      2 // https://github.com/golang/go/blob/39ad0fd0789872f9469167be7fe9578625ff246e/src/net/http/lex.go
      3 
      4 package sessions
      5 
      6 import "strings"
      7 
      8 var isTokenTable = [127]bool{
      9 	'!':  true,
     10 	'#':  true,
     11 	'$':  true,
     12 	'%':  true,
     13 	'&':  true,
     14 	'\'': true,
     15 	'*':  true,
     16 	'+':  true,
     17 	'-':  true,
     18 	'.':  true,
     19 	'0':  true,
     20 	'1':  true,
     21 	'2':  true,
     22 	'3':  true,
     23 	'4':  true,
     24 	'5':  true,
     25 	'6':  true,
     26 	'7':  true,
     27 	'8':  true,
     28 	'9':  true,
     29 	'A':  true,
     30 	'B':  true,
     31 	'C':  true,
     32 	'D':  true,
     33 	'E':  true,
     34 	'F':  true,
     35 	'G':  true,
     36 	'H':  true,
     37 	'I':  true,
     38 	'J':  true,
     39 	'K':  true,
     40 	'L':  true,
     41 	'M':  true,
     42 	'N':  true,
     43 	'O':  true,
     44 	'P':  true,
     45 	'Q':  true,
     46 	'R':  true,
     47 	'S':  true,
     48 	'T':  true,
     49 	'U':  true,
     50 	'W':  true,
     51 	'V':  true,
     52 	'X':  true,
     53 	'Y':  true,
     54 	'Z':  true,
     55 	'^':  true,
     56 	'_':  true,
     57 	'`':  true,
     58 	'a':  true,
     59 	'b':  true,
     60 	'c':  true,
     61 	'd':  true,
     62 	'e':  true,
     63 	'f':  true,
     64 	'g':  true,
     65 	'h':  true,
     66 	'i':  true,
     67 	'j':  true,
     68 	'k':  true,
     69 	'l':  true,
     70 	'm':  true,
     71 	'n':  true,
     72 	'o':  true,
     73 	'p':  true,
     74 	'q':  true,
     75 	'r':  true,
     76 	's':  true,
     77 	't':  true,
     78 	'u':  true,
     79 	'v':  true,
     80 	'w':  true,
     81 	'x':  true,
     82 	'y':  true,
     83 	'z':  true,
     84 	'|':  true,
     85 	'~':  true,
     86 }
     87 
     88 func isToken(r rune) bool {
     89 	i := int(r)
     90 	return i < len(isTokenTable) && isTokenTable[i]
     91 }
     92 
     93 func isNotToken(r rune) bool {
     94 	return !isToken(r)
     95 }
     96 
     97 func isCookieNameValid(raw string) bool {
     98 	if raw == "" {
     99 		return false
    100 	}
    101 	return strings.IndexFunc(raw, isNotToken) < 0
    102 }