MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / validQueryText

Function validQueryText

internal/server/middleware_request_text.go:332–354  ·  view source on GitHub ↗

validQueryText reports whether every key and value a handler could read out of this raw query string is bindableText. WHAT IT CHECKS AGAINST. url.ParseQuery is the same call r.URL.Query() makes, so the pairs checked in the decode step are exactly the pairs a handler can see — there is no equivalent

(rawQuery string)

Source from the content-addressed store, hash-verified

330// introduce anything, and none of these can put a NUL into a string that
331// had none.
332func validQueryText(rawQuery string) bool {
333 if rawQuery == "" {
334 return true
335 }
336 if !bindableText(rawQuery) {
337 return false
338 }
339 if !strings.Contains(rawQuery, "%") {
340 return true
341 }
342 q, _ := url.ParseQuery(rawQuery)
343 for key, values := range q {
344 if !bindableText(key) {
345 return false
346 }
347 for _, v := range values {
348 if !bindableText(v) {
349 return false
350 }
351 }
352 }
353 return true
354}
355
356// unicodeEscapePrefix is the four bytes that begin any JSON \u escape for a
357// character below U+0100. Built from bytes rather than written as a literal,

Callers 4

TestValidQueryTextFunction · 0.85
ValidateQueryFunction · 0.85
ValidateFormBodyFunction · 0.85

Calls 1

bindableTextFunction · 0.85