MCPcopy Create free account
hub / github.com/devploit/nomore403 / parsePayloadPositions

Function parsePayloadPositions

cmd/requester.go:3913–3936  ·  view source on GitHub ↗

parsePayloadPositions extracts marked segments from a URI template. Given a marker like "§" and URI "http://example.com/§100§/user/§200§", it returns the marked values ["100", "200"] and a template with internal placeholders.

(uri, marker string)

Source from the content-addressed store, hash-verified

3911// Given a marker like "§" and URI "http://example.com/§100§/user/§200§",
3912// it returns the marked values ["100", "200"] and a template with internal placeholders.
3913func parsePayloadPositions(uri, marker string) ([]string, string) {
3914 var positions []string
3915 template := uri
3916 idx := 0
3917
3918 for {
3919 start := strings.Index(template, marker)
3920 if start == -1 {
3921 break
3922 }
3923 rest := template[start+len(marker):]
3924 end := strings.Index(rest, marker)
3925 if end == -1 {
3926 break
3927 }
3928 value := rest[:end]
3929 positions = append(positions, value)
3930 placeholder := fmt.Sprintf("%s%d\x00", payloadPlaceholderPrefix, idx)
3931 template = template[:start] + placeholder + rest[end+len(marker):]
3932 idx++
3933 }
3934
3935 return positions, template
3936}
3937
3938// payloadPlaceholder returns the placeholder string for a given index.
3939func payloadPlaceholder(idx int) string {

Callers 3

setupRequestOptionsFunction · 0.85

Calls

no outgoing calls

Tested by 2