Skip to content

Perform Additional Origin Fixups#7326

Merged
jo merged 2 commits intomozilla:mainfrom
jo:perform-additional-origin-fixups
Apr 17, 2026
Merged

Perform Additional Origin Fixups#7326
jo merged 2 commits intomozilla:mainfrom
jo:perform-additional-origin-fixups

Conversation

@jo
Copy link
Copy Markdown
Contributor

@jo jo commented Apr 17, 2026

Add perform_additional_origin_fixups feature flag that repairs origin values which fail URL parsing (bare domains, FireFTP quirks, bare https: / https://, etc.) into parseable URLs instead of rejecting them. Scoped to the origin field only; form_action_origin keeps the stricter behavior, but can be disabled via ignore_form_action_origin_validation_errors.

Intended to be enabled on desktop during migration to salvage legacy/addon-generated entries.

Pull Request checklist

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes, or
      • There are corresponding PRs for our consumer applications that resolve the breaking changes and have been approved
  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGELOG.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due diligence applied in selecting them.

@jo jo force-pushed the perform-additional-origin-fixups branch 2 times, most recently from c3e7f3d to a862553 Compare April 17, 2026 10:10
@jo jo requested a review from bendk April 17, 2026 12:01
@jo jo mentioned this pull request Apr 17, 2026
5 tasks
@jo jo force-pushed the perform-additional-origin-fixups branch from a862553 to d30191d Compare April 17, 2026 13:13
Copy link
Copy Markdown
Contributor

@bendk bendk left a comment

Choose a reason for hiding this comment

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

Looks very nice to me. I'm picturing you going through some huge log of invalid URLs to get this code. I just had a couple naming/code organization suggestions, but nothing blocking.

Comment thread components/logins/src/db.rs Outdated

pub fn count_by_form_action_origin(&self, form_action_origin: &str) -> Result<i64> {
match LoginEntry::validate_and_fixup_origin(form_action_origin) {
match LoginEntry::validate_and_fixup_form_action_origin(form_action_origin) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe this should just be validate_form_action_origin at this point. I think all the fixup code has moved out of it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's right. I added the term normalize to hint that this methods returns something useful. For the origin I think fixup includes normalization, so I think that's fine.

Comment thread components/logins/src/login.rs Outdated
}

#[cfg(feature = "perform_additional_origin_fixups")]
fn looks_like_bare_ipv4(s: &str) -> bool {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When I first saw this I thought it was operating on the entire URL, but I think it's just the origin. Maybe the names could be updated to make it more clear.

What about creating a module called something like origin_fixup? That way it's obvious what all the functions are operating over. Also, you'd could have one #[cfg] attr around the entire module. Either an inline module or a separate file could work.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, good idea, thanks!

@jo jo force-pushed the perform-additional-origin-fixups branch from d30191d to b76c917 Compare April 17, 2026 15:12
Tessa Heidkamp and others added 2 commits April 17, 2026 17:14
The `perform_additional_origin_fixups` feature was unintentionally also
repairing `form_action_origin` values. Split the generic
`validate_and_fixup_origin` into two field-specific wrappers around a
new shared `parse_and_normalize_origin` helper.

Also documents the `keydb` and `perform_additional_origin_fixups`
features in Cargo.toml.
@jo jo force-pushed the perform-additional-origin-fixups branch from b76c917 to 047e1c9 Compare April 17, 2026 15:14
@jo jo added this pull request to the merge queue Apr 17, 2026
Merged via the queue into mozilla:main with commit 557e11b Apr 17, 2026
15 checks passed
@jo jo deleted the perform-additional-origin-fixups branch April 17, 2026 16:24
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.

2 participants