Skip to content

fix: handle & in search criteria, validate zip choices, and guard search url --save - #114

Draft
domfahey wants to merge 3 commits into
RealGeeks:mainfrom
domfahey:fix/search-validation-and-criteria
Draft

domfahey wants to merge 3 commits into
RealGeeks:mainfrom
domfahey:fix/search-validation-and-criteria

Conversation

@domfahey

@domfahey domfahey commented Nov 25, 2026 •

Copy link
Copy Markdown

Fixes how search criteria are parsed and checked (search check, search url --save, pages' --search-criteria). 5 files: about 490 lines of source and docs, about 960 lines of tests.

Behaviour changes

Input / command Before After
features=Pool & Spa split at & kept as one value
www.example.com?city=Miami, example.com/search/?… key became www.example.com?city parsed as a URL
city=Miami&, &city=Miami & sent in the value or key stray & dropped
=Miami, ?=Miami&…, a URL with no ? silently dropped or accepted usage error
search check zip=… not checked checked against the site's values
search url --save with ignored criteria saved a search that filters nothing refuses (exit 5); errors if the site returns no search_id
search run table footer "page 1 of 10" from per_page real page count, "of at least N" when capped

Smaller fixes: checkbox labels are kept when rows are merged, range choices are de-duplicated, search choices polygon --all is rejected up front, and Unicode-aware lowercase is used in search choices / search-forms fields.

Two judgement calls, please confirm

  1. Autocomplete index unreachable: the field is reported unchecked (value_check_error, exit 1 with --strict) instead of warning about case from the form's partial list, which could be wrong.
  2. Fixed catalog lists (fields not marked dynamic, such as type) are treated as complete, so autocomplete is not fetched for them.

Where to look

Three commits, one per topic. Each builds and passes the tests on its own, so they can be read one at a time:

  1. Parsing: parse_criteria (+ looks_like_host), with unit tests.
  2. Value checks: check_values and is_numeric_preset, with check_* tests. This commit holds the two judgement calls above.
  3. --save, output and docs: url, run_search, choices/fields, GUIDE.
  • tests/search.rs is long, but each test is one case named after its behaviour.

Checklist

  • cargo fmt, cargo clippy --all-targets -- -D warnings and cargo test pass
  • Behaviour changes documented in docs/GUIDE.md
  • No API keys, customer data or private site content

domfahey and others added 3 commits November 25, 2026 08:54
…a scheme

- a single key=value keeps `&` in its value (`subdivision=Town & Country`);
  only a stray `&` at either end is dropped
- `www.example.com?city=Miami` and `example.com/search/?…` parse as URLs
  instead of producing a key like `www.example.com?city`
- empty keys (`=Miami`, `?=Miami&…`) and URLs with no query string are
  usage errors instead of being dropped or accepted

Applies to `search check|run|url` and pages' `--search-criteria`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… not happen

- zip codes are checked against the site's values; other numeric fields
  (min/max ranges, price and beds presets, numeric multiselects, non-zip
  numeric autocomplete values) are still skipped as presets
- fixed catalog lists (fields not marked `dynamic`) are taken as complete,
  so the autocomplete index is not fetched for them
- if the autocomplete index cannot be read, the field is left unchecked
  (`value_check_error`; `--strict` exits 1) rather than warning from a
  partial list
- a field given only `all` is not listed in `values_checked`

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t the changes

- `search url --save` refuses to save when the site ignored a criterion
  (the saved search would filter nothing) and fails if the site returns no
  `search_id`
- `search run` table footer shows the real page count ("of at least N"
  when the total is capped; no bogus count for --per-page 0)
- checkbox labels are kept when form rows merge, range choices are
  de-duplicated, `search choices polygon --all` is rejected up front, a
  form answered with HTML is reported as such, and filters in `search
  choices` / `search-forms fields` lowercase Unicode text
- GUIDE: criteria parsing, --save, zip checks, fixed catalog lists and
  failed-autocomplete behaviour

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@domfahey
domfahey force-pushed the fix/search-validation-and-criteria branch from 876431e to 2f8e0bb Compare November 25, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant