detached c75e65d

fix(permission): guard empty-origin query and resolve merge dupes

commit
c75e65dfbc06e451116925414f59c22067b521c3
author
brice · · 2026-02-08 12:36 UTC
parent
f14455f
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
3 files · +20 -35
M cmd/dumber/main.go +2 -35
@@ -507,41 +507,6 @@ func buildUIDependencies(
507507 startupCrashReports []string,
508508 ) *ui.Dependencies {
509509 return &ui.Dependencies{
510- Ctx: ctx,
511- Config: cfg,
512- InitialURL: initialURL,
513- RestoreSessionID: restoreSessionID,
514- Theme: themeManager,
515- ColorResolver: colorResolver,
516- AdwaitaDetector: adwaitaDetector,
517- XDG: xdg.New(),
518- WebContext: stack.Context,
519- Pool: stack.Pool,
520- Settings: stack.Settings,
521- Injector: stack.Injector,
522- MessageRouter: stack.MessageRouter,
523- FilterManager: stack.FilterManager,
524- HistoryRepo: repos.history,
525- FavoriteRepo: repos.favorite,
526- ZoomRepo: repos.zoom,
527- PermissionRepo: repos.permission,
528- TabsUC: uc.tabs,
529- PanesUC: uc.panes,
530- HistoryUC: uc.history,
531- FavoritesUC: uc.favorites,
532- ZoomUC: uc.zoom,
533- PermissionUC: uc.permission,
534- NavigateUC: uc.navigate,
535- CopyURLUC: uc.copyURL,
536- Clipboard: uc.clipboard,
537- FaviconService: uc.favicon,
538- IdleInhibitor: idleInhibitor,
539- SessionRepo: repos.session,
540- SessionStateRepo: repos.sessionState,
541- CurrentSessionID: currentSessionID,
542- SnapshotUC: uc.snapshot,
543- CheckUpdateUC: uc.checkUpdate,
544- ApplyUpdateUC: uc.applyUpdate,
545510 Ctx: ctx,
546511 Config: cfg,
547512 InitialURL: initialURL,
@@ -560,11 +525,13 @@ func buildUIDependencies(
560525 HistoryRepo: repos.history,
561526 FavoriteRepo: repos.favorite,
562527 ZoomRepo: repos.zoom,
528+ PermissionRepo: repos.permission,
563529 TabsUC: uc.tabs,
564530 PanesUC: uc.panes,
565531 HistoryUC: uc.history,
566532 FavoritesUC: uc.favorites,
567533 ZoomUC: uc.zoom,
534+ PermissionUC: uc.permission,
568535 NavigateUC: uc.navigate,
569536 CopyURLUC: uc.copyURL,
570537 Clipboard: uc.clipboard,
@@ -507,41 +507,6 @@ func buildUIDependencies(
507 startupCrashReports []string,507 startupCrashReports []string,
508 ) *ui.Dependencies {508 ) *ui.Dependencies {
509 return &ui.Dependencies{509 return &ui.Dependencies{
510- Ctx: ctx,
511- Config: cfg,
512- InitialURL: initialURL,
513- RestoreSessionID: restoreSessionID,
514- Theme: themeManager,
515- ColorResolver: colorResolver,
516- AdwaitaDetector: adwaitaDetector,
517- XDG: xdg.New(),
518- WebContext: stack.Context,
519- Pool: stack.Pool,
520- Settings: stack.Settings,
521- Injector: stack.Injector,
522- MessageRouter: stack.MessageRouter,
523- FilterManager: stack.FilterManager,
524- HistoryRepo: repos.history,
525- FavoriteRepo: repos.favorite,
526- ZoomRepo: repos.zoom,
527- PermissionRepo: repos.permission,
528- TabsUC: uc.tabs,
529- PanesUC: uc.panes,
530- HistoryUC: uc.history,
531- FavoritesUC: uc.favorites,
532- ZoomUC: uc.zoom,
533- PermissionUC: uc.permission,
534- NavigateUC: uc.navigate,
535- CopyURLUC: uc.copyURL,
536- Clipboard: uc.clipboard,
537- FaviconService: uc.favicon,
538- IdleInhibitor: idleInhibitor,
539- SessionRepo: repos.session,
540- SessionStateRepo: repos.sessionState,
541- CurrentSessionID: currentSessionID,
542- SnapshotUC: uc.snapshot,
543- CheckUpdateUC: uc.checkUpdate,
544- ApplyUpdateUC: uc.applyUpdate,
545 Ctx: ctx,510 Ctx: ctx,
546 Config: cfg,511 Config: cfg,
547 InitialURL: initialURL,512 InitialURL: initialURL,
@@ -560,11 +525,13 @@ func buildUIDependencies(
560 HistoryRepo: repos.history,525 HistoryRepo: repos.history,
561 FavoriteRepo: repos.favorite,526 FavoriteRepo: repos.favorite,
562 ZoomRepo: repos.zoom,527 ZoomRepo: repos.zoom,
528+ PermissionRepo: repos.permission,
563 TabsUC: uc.tabs,529 TabsUC: uc.tabs,
564 PanesUC: uc.panes,530 PanesUC: uc.panes,
565 HistoryUC: uc.history,531 HistoryUC: uc.history,
566 FavoritesUC: uc.favorites,532 FavoritesUC: uc.favorites,
567 ZoomUC: uc.zoom,533 ZoomUC: uc.zoom,
534+ PermissionUC: uc.permission,
568 NavigateUC: uc.navigate,535 NavigateUC: uc.navigate,
569 CopyURLUC: uc.copyURL,536 CopyURLUC: uc.copyURL,
570 Clipboard: uc.clipboard,537 Clipboard: uc.clipboard,
M internal/application/usecase/handle_permission.go +5 -0
@@ -151,6 +151,11 @@ func (uc *HandlePermissionUseCase) QueryPermissionState(
151151 Str("type", string(permType)).
152152 Logger()
153153
154+ if origin == "" {
155+ log.Warn().Msg("query: empty origin, returning prompt")
156+ return entity.PermissionPrompt
157+ }
158+
154159 // Check stored permission first (including manual overrides on auto-allow types).
155160 record, err := uc.permRepo.Get(ctx, origin, permType)
156161 if err != nil {
@@ -151,6 +151,11 @@ func (uc *HandlePermissionUseCase) QueryPermissionState(
151 Str("type", string(permType)).151 Str("type", string(permType)).
152 Logger()152 Logger()
153 153
154+ if origin == "" {
155+ log.Warn().Msg("query: empty origin, returning prompt")
156+ return entity.PermissionPrompt
157+ }
158+
154 // Check stored permission first (including manual overrides on auto-allow types).159 // Check stored permission first (including manual overrides on auto-allow types).
155 record, err := uc.permRepo.Get(ctx, origin, permType)160 record, err := uc.permRepo.Get(ctx, origin, permType)
156 if err != nil {161 if err != nil {
M internal/application/usecase/handle_permission_test.go +13 -0
@@ -365,6 +365,19 @@ func TestHandlePermissionUseCase_QueryPermissionState_NoRecord(t *testing.T) {
365365 assert.Equal(t, entity.PermissionPrompt, state, "no record should return prompt")
366366 }
367367
368+func TestHandlePermissionUseCase_QueryPermissionState_EmptyOriginReturnsPrompt(t *testing.T) {
369+ ctx := testContext()
370+ permRepo := repomocks.NewMockPermissionRepository(t)
371+ dialog := portmocks.NewMockPermissionDialogPresenter(t)
372+
373+ uc := usecase.NewHandlePermissionUseCase(permRepo, dialog, permissionLoggerFromContext)
374+
375+ state := uc.QueryPermissionState(ctx, "", entity.PermissionTypeDisplay)
376+
377+ assert.Equal(t, entity.PermissionPrompt, state, "empty origin should return prompt")
378+ permRepo.AssertNotCalled(t, "Get")
379+}
380+
368381 func TestHandlePermissionUseCase_NonPersistableNotSaved(t *testing.T) {
369382 ctx := testContext()
370383 permRepo := repomocks.NewMockPermissionRepository(t)
@@ -365,6 +365,19 @@ func TestHandlePermissionUseCase_QueryPermissionState_NoRecord(t *testing.T) {
365 assert.Equal(t, entity.PermissionPrompt, state, "no record should return prompt")365 assert.Equal(t, entity.PermissionPrompt, state, "no record should return prompt")
366 }366 }
367 367
368+func TestHandlePermissionUseCase_QueryPermissionState_EmptyOriginReturnsPrompt(t *testing.T) {
369+ ctx := testContext()
370+ permRepo := repomocks.NewMockPermissionRepository(t)
371+ dialog := portmocks.NewMockPermissionDialogPresenter(t)
372+
373+ uc := usecase.NewHandlePermissionUseCase(permRepo, dialog, permissionLoggerFromContext)
374+
375+ state := uc.QueryPermissionState(ctx, "", entity.PermissionTypeDisplay)
376+
377+ assert.Equal(t, entity.PermissionPrompt, state, "empty origin should return prompt")
378+ permRepo.AssertNotCalled(t, "Get")
379+}
380+
368 func TestHandlePermissionUseCase_NonPersistableNotSaved(t *testing.T) {381 func TestHandlePermissionUseCase_NonPersistableNotSaved(t *testing.T) {
369 ctx := testContext()382 ctx := testContext()
370 permRepo := repomocks.NewMockPermissionRepository(t)383 permRepo := repomocks.NewMockPermissionRepository(t)

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close