SYS-REQ-114
(path string, start int)
| 97 | |
| 98 | // SYS-REQ-114 |
| 99 | func parseQuotedPathKey(path string, start int) (string, int, error) { |
| 100 | contentStart := start + 1 |
| 101 | for pos := contentStart; pos < len(path); pos++ { |
| 102 | switch path[pos] { |
| 103 | case '\\': |
| 104 | // Skip the escaped byte while locating the closing quote. Unescape |
| 105 | // below performs complete JSON escape validation. |
| 106 | pos++ |
| 107 | if pos >= len(path) { |
| 108 | return "", 0, errUnterminatedKey |
| 109 | } |
| 110 | case '"': |
| 111 | content := path[contentStart:pos] |
| 112 | if strings.IndexByte(content, '\\') == -1 { |
| 113 | return content, pos + 1, nil |
| 114 | } |
| 115 | |
| 116 | unescaped, err := Unescape([]byte(content), nil) |
| 117 | if err != nil { |
| 118 | return "", 0, errMalformedPath |
| 119 | } |
| 120 | return string(unescaped), pos + 1, nil |
| 121 | default: |
| 122 | if path[pos] < 0x20 { |
| 123 | return "", 0, errMalformedPath |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | return "", 0, errUnterminatedKey |
| 129 | } |
| 130 | |
| 131 | // SYS-REQ-114 |
| 132 | func parseBracketPathComponent(path string, start int) (string, int, error) { |