MCPcopy Create free account
hub / github.com/crewjam/saml / parseRedirect

Function parseRedirect

testsaml/parse.go:34–49  ·  view source on GitHub ↗
(u *url.URL, param, what string)

Source from the content-addressed store, hash-verified

32}
33
34func parseRedirect(u *url.URL, param, what string) ([]byte, error) {
35 compressed, err := base64.StdEncoding.DecodeString(u.Query().Get(param))
36 if err != nil {
37 return nil, fmt.Errorf("cannot decode %s: %w", what, err)
38 }
39 r := flate.NewReader(bytes.NewReader(compressed))
40 defer r.Close() //nolint:errcheck // closing a flate reader over a bytes.Reader cannot fail meaningfully
41 buf, err := io.ReadAll(io.LimitReader(r, MaxDecompressedSize+1))
42 if err != nil {
43 return nil, fmt.Errorf("cannot decompress %s: %w", what, err)
44 }
45 if len(buf) > MaxDecompressedSize {
46 return nil, fmt.Errorf("cannot decompress %s: %w", what, ErrTooLarge)
47 }
48 return buf, nil
49}

Callers 2

ParseRedirectRequestFunction · 0.85
ParseRedirectResponseFunction · 0.85

Calls 2

GetMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected