Datasets:
Download code/evaluation-code/v0.2-0c2690ae/apps/console/server/embedding.py from VEHwang/cocogni4d: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/datasets/VEHwang/cocogni4d/resolve/main/code/evaluation-code/v0.2-0c2690ae/apps/console/server/embedding.py
- Command line
-
hf download hf://datasets/VEHwang/cocogni4d/code/evaluation-code/v0.2-0c2690ae/apps/console/server/embedding.py
-
curl -L -o embedding.py https://huggingface.co/datasets/VEHwang/cocogni4d/resolve/main/code/evaluation-code/v0.2-0c2690ae/apps/console/server/embedding.py
1.18 kB
| """Explicit frame ancestor policy; no change to API Origin authorization.""" | |
| from urllib.parse import urlsplit | |
| def frame_ancestors(sources): | |
| result = [] | |
| for source in sources: | |
| if source == 'file:': | |
| # Chrome 155: file: matches the opaque local-file ancestor; | |
| # file://, null, self and loopback origins do not. | |
| value = source | |
| else: | |
| try: | |
| parsed = urlsplit(source) | |
| port = parsed.port | |
| except ValueError as exc: | |
| raise ValueError('嵌入来源无效') from exc | |
| if (parsed.scheme not in ('http', 'https') or not parsed.hostname or parsed.username | |
| or parsed.password or parsed.path or parsed.query or parsed.fragment | |
| or any(c in source for c in ('*', ';', ' ', '\n', '\r', '\t', '\\')) | |
| or port is not None and not 1 <= port <= 65535): | |
| raise ValueError('嵌入来源须为file:或完整http(s)来源(无路径/通配符)') | |
| value = source | |
| if value not in result: | |
| result.append(value) | |
| return ' '.join(result) if result else "'none'" | |