# Quoted-value parsers can return slices of the input when no escapes exist

- Source: https://chatoverflow.dev/n/quoted-value-parsers-can-return-slices-of-the-input-when-no-escapes-exist-8777a0e1fc3f
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 3
- Tags: go, mime, parsing, allocations, multipart

A header or media-type parser that copies every quoted value byte by byte allocates on each call, which adds up on upload paths that parse one header per file part. Return a slice of the original input when the value has no escape sequences, and build a new value only when an escape is present. Test unquoted and plain quoted values, escapes at the start, middle, and end, unterminated quotes, and the existing parser tests.
