feat(rewrite): validate rewrite rules at save time with helpful error messages#4453
Open
dave-atx wants to merge 6 commits into
Open
feat(rewrite): validate rewrite rules at save time with helpful error messages#4453dave-atx wants to merge 6 commits into
dave-atx wants to merge 6 commits into
Conversation
…itors Reject malformed content- and URL-rewrite rules when a feed is created or modified (REST API, Google Reader, OPML import, and both UI forms), while warning-only at refresh so already-stored rules never break. - New validator.IsValidRewriteRules mapping parse errors to localized keys; wired into feed create/modify and the UI subscription form. Also fill the UI feed-edit gap where RewriteRules was never sent for validation. - Validate UrlRewriteRules everywhere and add the missing error key. - Convert the scraper, content-rewrite, and URL-rewrite fields to monospaced, auto-growing, resizable textareas; give the filter, custom CSS/JS, and external-font-host fields the same monospaced treatment. - English (en_US) strings for the new error keys; unit + API integration tests.
Machine-translated (unreviewed) strings for the content- and URL-rewrite validation error keys across 22 locales.
dave-atx
force-pushed
the
rule-validation
branch
from
July 11, 2026 23:49
6ddadee to
ab456a5
Compare
Contributor
Author
|
Changed the i18n's commit description to use |
Make sure URL rewrite rules that don't call the correct "function" get
marked as invalid. For example, 'typo("find"|"replace")' is now marked
as invalid at save time.
Contributor
Author
|
Also noticed that the URL Rewrite Rules field was not fully validating, so added the fix for that while this PR is in the area. Specifically, it now flags missing 'functions' as invalid, e.g.: another one I found the hard way 😆 🫠 |
fguillot
reviewed
Jul 18, 2026
fguillot
left a comment
Member
There was a problem hiding this comment.
- After a rewrite validation error,
updateFeedrerenders without settinghasProxyConfigured, so resubmitting silently storesFetchViaProxy=false. replace("["|"x")passes validation even though its regex cannot compile, causing the rule to silently do nothing.
The replace and replace_title rules compile their first argument as a regular expression (regexp.Compile) at apply time, silently doing nothing when the pattern is invalid. Flag those rules with regexArg in the knownRules table and reject invalid patterns at save time via a new RuleErrInvalidRegexp error, so users get immediate feedback instead of a rule that quietly never matches.
Add error.feed_rewrite_rule_invalid_regex across all locales. Machine-translated (unreviewed), except nan_Latn_pehoeji, which was hand-derived from the sibling feed_rewrite_rule_* strings to match that locale's existing vocabulary.
updateFeed re-renders edit_feed.html when validation fails but never set hasProxyConfigured, so the 'fetch via proxy' checkbox vanished from the re-rendered form for users with a proxy configured. Set it to match feed_edit.go. Latent since the proxy option was introduced (2020).
Contributor
Author
|
Updated to fix both of those issues. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a few quality-of-life improvements for working with content / URL / entry rewrite rules:
<textarea>'sso they can be resized by the user in their browser during editing if desired.I scratch this itch after spending an inordinate amount of time discovering that I had forgotten to double escape a backslash character in a content rewrite rule I was trying out. 🫠
The
i18noutside of English is all LLM generated, so almost certainly is nonsensical for some languages.Apologies for the size of the PR. The bulk of the file count is internationalization and tests.