Skip to content

Normalize and safely encode FreshRSS categories - #21

Closed
Skulldorom wants to merge 1 commit into
mainfrom
codex/normalize-category-parameter-in-main.py
Closed

Normalize and safely encode FreshRSS categories#21
Skulldorom wants to merge 1 commit into
mainfrom
codex/normalize-category-parameter-in-main.py

Conversation

@Skulldorom

Copy link
Copy Markdown
Owner

Motivation

  • Ensure category query values are canonicalized so user-supplied whitespace does not produce invalid or surprising upstream requests.
  • Treat whitespace-only category values as if no category was provided, falling back to the reading list stream.
  • Prevent unsafe path injection and preserve characters by encoding the label as a single URL path segment when constructing the FreshRSS stream URL.

Description

  • Add from urllib.parse import quote and use quote(category_label, safe="") to encode the category as one URL path segment before building the upstream stream path.
  • Normalize the category parameter with category.strip() and treat non-string or empty/whitespace results as no category.
  • Constrain the FastAPI Query for category with max_length=200 to impose a reasonable query-string length limit.
  • Add parameterized tests in tests/test_main.py (test_freshrss_unread_normalizes_and_encodes_category) that assert the exact upstream URL for categories containing spaces, slashes, percent signs, question marks, Unicode, and whitespace-only inputs.

Testing

  • Ran the test suite with uv run pytest -q, and all tests passed (15 passed).
  • The new parameterized tests verify exact upstream URL construction and succeeded as part of the test run.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fd527cff7e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread main.py
stream_id = f"user/-/label/{category_label}" if category_label else "user/-/state/com.google/reading-list"
category_label = category.strip() if isinstance(category, str) else None
stream_id = (
f"user/-/label/{quote(category_label, safe='')}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle dot-only labels before building the path

When the normalized category is . or .., quote(..., safe='') leaves it unchanged because dots are always URL-safe. The locked Requests 2.33.1 then resolves these as path segments while preparing the request: label/. becomes label/, and label/.. becomes user/-/, so FreshRSS receives a different stream ID rather than the requested category. Reject these labels or construct the request so their path segment cannot be normalized; the mocked requests.get tests currently inspect the URL before this preparation occurs.

Useful? React with 👍 / 👎.

@Skulldorom

Copy link
Copy Markdown
Owner Author

Superseded by #25 — all four PRs merged with conflict resolution and review fixes applied.

@Skulldorom Skulldorom closed this Jul 20, 2026
@Skulldorom
Skulldorom deleted the codex/normalize-category-parameter-in-main.py branch July 20, 2026 10:01
Skulldorom added a commit that referenced this pull request Jul 20, 2026
merge: consolidate PRs #20, #21, #22, #23 with review fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant