|
47 | 47 | # `timeout: 30` (a YAML-ish literal) are not rejected — a real Sourcegraph |
48 | 48 | # filter value is never separated from its colon by whitespace. |
49 | 49 | _INJECTED_FILTER_RE = re.compile( |
50 | | - r"(^|[\s(])-?(count|repo|r|timeout|context|rev|revision|fork|archived|select):(?=[^\s)])", re.IGNORECASE |
| 50 | + r"(^|[\s(])-?(count|repo|r|timeout|context|rev|revision|fork|archived|select|patterntype):(?=[^\s)])", |
| 51 | + re.IGNORECASE, |
51 | 52 | ) |
52 | 53 |
|
53 | 54 | # C0 (0x00-0x1F) and C1 (0x7F-0x9F) control characters, including ESC (0x1B) |
@@ -106,8 +107,8 @@ def _validate_query(query: str, repo: str | None) -> None: |
106 | 107 | raise ValueError(f"query must be at most {MAX_QUERY_BYTES} bytes") |
107 | 108 | if _INJECTED_FILTER_RE.search(query): |
108 | 109 | raise ValueError( |
109 | | - "query must not contain count:, repo:, timeout:, context:, rev:, revision:, fork:, archived:, or " |
110 | | - "select: filters" |
| 110 | + "query must not contain count:, repo:, timeout:, context:, rev:, revision:, fork:, archived:, " |
| 111 | + "select:, or patterntype: filters" |
111 | 112 | ) |
112 | 113 | if repo and re.search(r"\s", repo): |
113 | 114 | raise ValueError("repo must not contain whitespace") |
@@ -475,7 +476,12 @@ def code_search( |
475 | 476 | typer.Argument( |
476 | 477 | help=( |
477 | 478 | "Search query (supports Sourcegraph syntax). Defaults to file matches; " |
478 | | - "pass your own `type:` filter (e.g. `type:commit`) to override." |
| 479 | + "pass your own `type:` filter (e.g. `type:commit`) to override. Whitespace is " |
| 480 | + "not a reliable AND: whether `seedWidget serializeValue` matches both terms or " |
| 481 | + "one literal phrase depends on the service's pattern-type default, which this " |
| 482 | + "command does not pin. Join multiple concepts with explicit `AND` instead " |
| 483 | + "(`seedWidget AND serializeValue`) to get the same result regardless of that " |
| 484 | + "default." |
479 | 485 | ), |
480 | 486 | ), |
481 | 487 | ], |
|
0 commit comments