SYS-REQ-114
(path string, start int)
| 130 | |
| 131 | // SYS-REQ-114 |
| 132 | func parseBracketPathComponent(path string, start int) (string, int, error) { |
| 133 | end := start + 1 |
| 134 | for end < len(path) && path[end] != ']' { |
| 135 | if path[end] == '[' || path[end] == '"' { |
| 136 | return "", 0, errMalformedPath |
| 137 | } |
| 138 | end++ |
| 139 | } |
| 140 | if end == len(path) || end == start+1 { |
| 141 | return "", 0, errMalformedPath |
| 142 | } |
| 143 | |
| 144 | if path[start+1] == '*' { |
| 145 | if end != start+2 { |
| 146 | return "", 0, errMalformedPath |
| 147 | } |
| 148 | } else { |
| 149 | for pos := start + 1; pos < end; pos++ { |
| 150 | if path[pos] < '0' || path[pos] > '9' { |
| 151 | return "", 0, errMalformedPath |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | return path[start : end+1], end + 1, nil |
| 157 | } |
| 158 | |
| 159 | // CompiledPath stores a parsed path for repeated operations. |
| 160 | // SYS-REQ-114 |