| 142 | |
| 143 | |
| 144 | def _identifier(value, suite=False): |
| 145 | if type(value) is not str or not value: |
| 146 | _error("input", "registry identifier must be a nonempty string") |
| 147 | try: |
| 148 | data = value.encode("utf-8", "strict") |
| 149 | except UnicodeError: |
| 150 | _error("input", "registry identifier is not valid UTF-8") |
| 151 | if any(char in data for char in (0, 9, 10, 13)) or (suite and b":" in data): |
| 152 | _error("input", "registry identifier violates producer grammar") |
| 153 | if not suite and value == "*": |
| 154 | _error("input", "setup test name is reserved") |
| 155 | # Native routing uses each identifier as one filesystem component. The |
| 156 | # pure producer accepts a wider byte grammar; those routes are unsupported. |
| 157 | if value in (".", "..") or "/" in value or "\\" in value: |
| 158 | _error("unsupported", "registry identifier cannot be a native path component") |
| 159 | if not suite and value in ("_setup", "_setup.child"): |
| 160 | _error("unsupported", "registry test collides with native setup routing") |
| 161 | return data |
| 162 | |
| 163 | |
| 164 | def _registry(path, image): |