// needsEscape checks whether a byte in a potential dbus ObjectPath needs to be escaped
498206
func needsEscape(i int, b byte) bool {
	// Escape everything that is not a-z-A-Z-0-9
	// Also escape 0-9 if it's the first character
	return strings.IndexByte(alphanum, b) == -1 ||
		(i == 0 && strings.IndexByte(num, b) != -1)
}
251125
func (s *Server) needJWT() bool {
	for _, r := range s.Resources {
		if r.NeedJWT() {
			return true
		}
	}
	return false
}
610690
func (ctx *Context) FormEscape(key string, defaults ...string) string {
	return (*Forms)(ctx.req).MustEscape(key, defaults...)
}
384204
func (e *LoginWithPaperKey) RequiredUIs() []libkb.UIKind {
	return []libkb.UIKind{
		libkb.LogUIKind,
		libkb.SecretUIKind,
	}
}
919259
func NeedValue(name string) bool {
	switch name {
	case ast.AggFuncSum, ast.AggFuncAvg, ast.AggFuncFirstRow, ast.AggFuncMax, ast.AggFuncMin,
		ast.AggFuncGroupConcat, ast.AggFuncBitOr, ast.AggFuncBitAnd, ast.AggFuncBitXor:
		return true
	default:
		return false
	}
}
715754
func PathBusEscape(path string) string {
	// Special case the empty string
	if len(path) == 0 {
		return "_"
	}
	n := []byte{}
	for i := 0; i < len(path); i++ {
		c := path[i]
		if needsEscape(i, c) {
			e := fmt.Sprintf("_%x", c)
			n = append(n, []byte(e)...)
		} else {
			n = append(n, c)
		}
	}
	return string(n)
}
269533
func (m RoundingMode) needsInc(odd bool, r int, pos bool) bool {
	switch m {
	case AwayFromZero:
		return true // always up
	case ToZero:
		return false // always down
	case ToPositiveInf:
		return pos // up if positive
	case ToNegativeInf:
		return !pos // down if negative

	//  r <  0: closer to higher
	//  r == 0: halfway
	//  r >  0: closer to lower
	case ToNearestEven:
		if r != 0 {
			return r > 0
		}
		return odd
	case ToNearestAway:
		return r >= 0
	default:
		return false
	}
}
111325
func (st *State) NeedsCleanup() (bool, error) {
	cleanups, closer := st.db().GetCollection(cleanupsC)
	defer closer()
	count, err := cleanups.Count()
	if err != nil {
		return false, err
	}
	return count > 0, nil
}
194679
func (e *PGPDecrypt) RequiredUIs() []libkb.UIKind {
	return []libkb.UIKind{libkb.SecretUIKind, libkb.LogUIKind, libkb.PgpUIKind}
}
380049
func (t *tree) parseAutoescape(attrs map[string]string) ast.AutoescapeType {
	switch val := attrs["autoescape"]; val {
	case "":
		return ast.AutoescapeUnspecified
	case "contextual":
		return ast.AutoescapeContextual
	case "deprecated-contextual":
		return ast.AutoescapeContextual
	case "true":
		return ast.AutoescapeOn
	case "false":
		return ast.AutoescapeOff
	default:
		t.errorf(`expected "true", "false", or "contextual" for autoescape, got %q`, val)
	}
	panic("unreachable")
}
1313522
func Needs(m pgs.Message, wk WellKnown) bool {

	for _, f := range m.Fields() {
		var rules validate.FieldRules
		if _, err := f.Extension(validate.E_Rules, &rules); err != nil {
			continue
		}

		switch {
		case f.Type().IsRepeated() && f.Type().Element().ProtoType() == pgs.StringT:
			if strRulesNeeds(rules.GetRepeated().GetItems().GetString_(), wk) {
				return true
			}
		case f.Type().IsMap():
			if f.Type().Key().ProtoType() == pgs.StringT &&
				strRulesNeeds(rules.GetMap().GetKeys().GetString_(), wk) {
				return true
			}
			if f.Type().Element().ProtoType() == pgs.StringT &&
				strRulesNeeds(rules.GetMap().GetValues().GetString_(), wk) {
				return true
			}
		case f.Type().ProtoType() == pgs.StringT:
			if strRulesNeeds(rules.GetString_(), wk) {
				return true
			}
		}
	}

	return false
}
434357
func HTMLEscape(w io.Writer, b []byte) {
	last := 0
	for i, c := range b {
		var html []byte
		switch c {
		case '"':
			html = htmlQuot
		case '\'':
			html = htmlApos
		case '&':
			html = htmlAmp
		case '<':
			html = htmlLt
		case '>':
			html = htmlGt
		default:
			continue
		}
		w.Write(b[last:i])
		w.Write(html)
		last = i + 1
	}
	w.Write(b[last:])
}
593496
func (e *EvalEligibility) HasEscaped() bool {
	if e.jobEscaped {
		return true
	}

	for _, escaped := range e.tgEscapedConstraints {
		if escaped {
			return true
		}
	}

	return false
}
28283
func (ctx *Context) ParamEscape(key string, defaults ...string) string {
	return ctx.Params().MustEscape(key, defaults...)
}
1071547
func htmlEscapeString(w io.Writer, str string) {
	last := 0
	for i := 0; i < len(str); i++ {
		var html []byte
		switch str[i] {
		case '"':
			html = htmlQuot
		case '\'':
			html = htmlApos
		case '&':
			html = htmlAmp
		case '<':
			html = htmlLt
		case '>':
			html = htmlGt
		default:
			continue
		}
		io.WriteString(w, str[last:i])
		w.Write(html)
		last = i + 1
	}
	io.WriteString(w, str[last:])
}
829458
func (m *clusterQuotaMapper) requireNamespace(namespace metav1.Object) bool {
	m.lock.RLock()
	selectionFields, exists := m.requiredNamespaceToLabels[namespace.GetName()]
	m.lock.RUnlock()

	if selectionFieldsMatch(selectionFields, exists, namespace) {
		return false
	}

	m.lock.Lock()
	defer m.lock.Unlock()
	selectionFields, exists = m.requiredNamespaceToLabels[namespace.GetName()]
	if selectionFieldsMatch(selectionFields, exists, namespace) {
		return false
	}

	m.requiredNamespaceToLabels[namespace.GetName()] = GetSelectionFields(namespace)
	return true
}
460748
func needsQuote(s string) bool {
	for i := range s {
		if s[i] < 0x20 || s[i] > 0x7e || s[i] == ' ' || s[i] == '\\' || s[i] == '"' {
			return true
		}
	}
	return false
}