(cacheMap map[string]any, entry *CacheMemoryEntry)
| 257 | } |
| 258 | |
| 259 | func parseCacheMemoryAllowedExtensions(cacheMap map[string]any, entry *CacheMemoryEntry) error { |
| 260 | allowedExts, exists := cacheMap["allowed-extensions"] |
| 261 | if !exists { |
| 262 | return nil |
| 263 | } |
| 264 | extArray, ok := allowedExts.([]any) |
| 265 | if !ok { |
| 266 | return nil |
| 267 | } |
| 268 | entry.AllowedExtensions = make([]string, 0, len(extArray)) |
| 269 | for _, ext := range extArray { |
| 270 | extStr, ok := ext.(string) |
| 271 | if !ok { |
| 272 | continue |
| 273 | } |
| 274 | if !isValidFileExtension(extStr) { |
| 275 | return fmt.Errorf("invalid allowed-extension %q: must start with '.' followed by alphanumeric characters only (e.g. .json)", extStr) |
| 276 | } |
| 277 | entry.AllowedExtensions = append(entry.AllowedExtensions, extStr) |
| 278 | } |
| 279 | return nil |
| 280 | } |
| 281 | |
| 282 | func applyDefaultAllowedExtensions(entry *CacheMemoryEntry) { |
| 283 | if len(entry.AllowedExtensions) == 0 { |
no test coverage detected