(content: str)
| 456 | |
| 457 | |
| 458 | def validate_env_source(content: str) -> str: |
| 459 | normalized = content.replace("\r\n", "\n").replace("\r", "\n") |
| 460 | |
| 461 | for line_number, line in enumerate(normalized.splitlines(), start=1): |
| 462 | stripped = line.strip() |
| 463 | if not stripped or stripped.startswith("#"): |
| 464 | continue |
| 465 | if not _ENV_SOURCE_LINE_PATTERN.match(line): |
| 466 | raise ValueError( |
| 467 | f"第 {line_number} 行不是合法的 KEY=VALUE 格式。" |
| 468 | ) |
| 469 | |
| 470 | return normalized |
| 471 | |
| 472 | |
| 473 | def build_config_page_data( |
no outgoing calls