// PathEscape escapes all segemnts of a given path
8409
func PathEscape(path string) string {
	s := strings.Split(path, "/")
	for i, e := range s {
		s[i] = url.PathEscape(e)
	}
	return strings.Join(s, "/")
}
182248
func (e Entry) Path() (string, error) {
	decodedName, err := govis.Unvis(e.Name, DefaultVisFlags)
	if err != nil {
		return "", err
	}
	decodedName = CleanPath(decodedName)
	if e.Parent == nil || e.Type == FullType {
		return decodedName, nil
	}
	parentName, err := e.Parent.Path()
	if err != nil {
		return "", err
	}
	return CleanPath(filepath.Join(parentName, decodedName)), nil
}
417113
func JSEscapeString(s string) string {
	// Avoid allocation if we can.
	if strings.IndexFunc(s, jsIsSpecial) < 0 {
		return s
	}
	var b bytes.Buffer
	JSEscape(&b, []byte(s))
	return b.String()
}
409530
func (p *PathSpec) URLEscape(uri string) string {
	// escape unicode letters
	parsedURI, err := url.Parse(uri)
	if err != nil {
		// if net/url can not parse URL it means Sanitize works incorrectly
		panic(err)
	}
	x := parsedURI.String()
	return x
}
925226
func PathPrep(ugly bool, in string) string {
	if ugly {
		return Uglify(in)
	}
	return PrettifyPath(in)
}
1159340
func (s *scanner) scanEscaped(r rune) bool {
	if s.mode&scanEscape == 0 {
		return false
	}
	if r == '$' {
		if s.peek() == '$' {
			return true
		}
	}
	if r != '\\' {
		return false
	}
	switch s.peek() {
	case '/', '\\':
		return true
	default:
		return false
	}
}
1063529
func (r RequestParams) GetEscape(key string) string {
	return DecodeQuery(DecodeQuery(r.Get(key)))
}
627228
func pathMatch(pattern, path string) bool {
	if len(pattern) == 0 {
		// should not happen
		return false
	}
	n := len(pattern)
	if pattern[n-1] != '/' {
		return pattern == path
	}
	return len(path) >= n && path[0:n] == pattern
}
491458
func (s *SVG) Path(str string, args map[string]interface{}) {
	pathStr := fmt.Sprintf("<path d='%s' %s />", str, s.WriteArgs(args))
	s.svgString += pathStr
}
796720
func (r *route) Path(path string) types.Route {
	r.path = path
	return r
}
1147963
func QueryEscape(str string) string {
	encodeString := url.QueryEscape(str)

	encodeString = strings.Replace(encodeString, "+", "%20", -1)
	encodeString = strings.Replace(encodeString, "*", "%2A", -1)

	return encodeString
}
1095647
func QueryEscape(params map[string]string, buf *bytes.Buffer) ([]byte, bool) {
	s, b := Query(params, buf)
	if len(s) == 0 {
		return nil, b
	}

	return []byte(url.QueryEscape(string(s))), false // TODO: remove bytes convert
}
1303439
func (c *cookies) MustEscape(key string, defaults ...string) string {
	ck, err := c.req.Cookie(key)
	if err != nil {
		if len(defaults) > 0 {
			return defaults[0]
		}
		return ""
	}
	return template.HTMLEscapeString(ck.Value)
}
1185301
func (ns *Namespace) HTMLEscape(s interface{}) (string, error) {
	ss, err := cast.ToStringE(s)
	if err != nil {
		return "", err
	}

	return html.EscapeString(ss), nil
}
1238784
func (ns *Namespace) HTMLUnescape(s interface{}) (string, error) {
	ss, err := cast.ToStringE(s)
	if err != nil {
		return "", err
	}

	return html.UnescapeString(ss), nil
}
1060514
func pathMatches(path, spec string) bool {
	// Allow wildcard match
	if spec == "*" {
		return true
	}
	// Allow exact match
	if spec == path {
		return true
	}
	// Allow a trailing * subpath match
	if strings.HasSuffix(spec, "*") && strings.HasPrefix(path, strings.TrimRight(spec, "*")) {
		return true
	}
	return false
}
292067
func NewEscapeProxy(r io.Reader, escapeKeys []byte) io.Reader {
	return &escapeProxy{
		escapeKeys: escapeKeys,
		r:          r,
	}
}