Add configurable save directory for Autofill-saved entries - #128
Add configurable save directory for Autofill-saved entries#128AuthenticSm1les wants to merge 1 commit into
Conversation
Credentials saved via the Autofill framework (the system "Save to Password Store?" prompt shown while the app is closed) were always written directly to the repository root, with no way to route them into a category subfolder like a user-organized store might use. Add a "Save directory" setting under Settings > Autofill that lets users specify a root subfolder; Autofill-originated saves are then resolved under that folder instead of the store root. Leaving it unset preserves the existing behavior exactly. The in-app "+" entry creation flow is unaffected in every case. Fixes pando85#127
pando85
left a comment
There was a problem hiding this comment.
Thanks for this. I like the feature and the current Autofill-only scope, and I'm happy to merge it after a couple of changes.
There are two things I'd like to address before merging:
-
Validate the configured path instead of silently rewriting it
Currently
saveDirectory()removes blank and..path segments:.split('/') .filter { it.isNotBlank() && it != ".." } .joinToString("/")
This means something like
work/../personalsilently becomeswork/personal, which is safe from straightforward traversal but surprising behavior.I'd prefer the configured value to be treated as a relative path and rejected/fallback safely when invalid, rather than mutated into a different path.
Please cover at least:
- empty value → repository root
www→ validwww/personal→ valid/www→ invalid../www→ invalidwww/../personal→ invalid./ empty path components → invalid or explicitly normalized
It would also be cleaner if
AutofillPreferencesonly returned the configured relative directory rather than depending onPasswordRepository; the caller already has the repository root and can resolve it there. I don't consider that architectural cleanup a hard requirement if path handling is otherwise robust. -
Add unit tests for the path handling
Since the new behavior is mostly path parsing/resolution, I'd like this logic covered by unit tests rather than relying only on compilation and manual verification.
After that, please also confirm the two manual cases from the PR description:
- configured directory: an Autofill save actually lands below that directory
- empty setting: existing root-save behavior is preserved
No need to expand this PR to change the normal in-app + flow or add a folder picker. Keeping this focused on Autofill is good.
With those changes, this should be ready to merge. Thanks!
Summary
AutofillPreferences.saveDirectory()) that lets users specify a root subfolder (e.g.www); Autofill-originated saves are then resolved under that folder instead of the store root.AutofillSaveActivity) — leaving it unset preserves existing behavior exactly, and the in-app "+" entry creation flow is unaffected in every case.Fixes #127
Test plan
./gradlew :app:compileDebugKotlin— builds clean./gradlew spotlessCheck— formatting passeswww, trigger an Autofill save prompt on a new site, confirm the entry lands atwww/<site>/<file>instead of the store root