func (c *C) SanitizerMangler(san *sanitize.Extractor) { san.AddFuncs(sanitize.FuncMap{ "file": func(dat interface{}, s sanitize.Scheme) (interface{}, error) { temps := c.fileSys.Temporaries() if temps.Exists(s.Key) { return nil, fmt.Errorf("Can't find key amongst files.") } temp := temps.Select(s.Key) if len(temp) > 0 { c.fileBiz[s.Key] = temp } return nil, nil }, }) }
func (c *C) SanitizerMangler(san *sanitize.Extractor) { san.AddFuncs(sanitize.FuncMap{ "file": func(dat interface{}, s sanitize.Scheme) (interface{}, error) { if c.uni.Req.MultipartForm.File == nil { return nil, fmt.Errorf("No files at all.") } val, has := c.uni.Req.MultipartForm.File[s.Key] if !has { return nil, fmt.Errorf("Can't find key amongst files.") } ret := []interface{}{} for _, v := range val { ret = append(ret, v) } c.fileBiz[s.Key] = ret return ret, nil }, }) }
func (c *C) SanitizerMangler(san *sanitize.Extractor) { san.AddFuncs(sanitize.FuncMap{ "fkid": func(dat interface{}, s sanitize.Scheme) (interface{}, error) { cs, _ := s.Specific["commaSeparated"].(bool) if cs { ret := []interface{}{} split := strings.Split(dat.(string), ",") for _, v := range split { idstr := strings.Trim(v, " ") id, err := c.ctx.Db().ToId(idstr) if err != nil { return nil, err } ret = append(ret, id) } return ret, nil } str := strings.Trim(dat.(string), " ") return c.ctx.Db().ToId(str) }, }) }