Skip to content

Commit

Permalink
[components] Closes mozilla-mobile/android-components#7637: Add allow…
Browse files Browse the repository at this point in the history
…ed redirect URL list for AppLinksInterceptor

UltraBlame original commit: 2ba2e1c21936de6049eece2d4ab9c79eadd5e53e
  • Loading branch information
marco-c committed Jun 1, 2024
1 parent fd95ef1 commit 6277ab0
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,23 @@ if
available
.
*
param
allowRedirectUrls
A
set
of
URLs
that
allows
intercept
when
onLoadRequest
is
triggered
by
redirect
.
*
/
Suppress
(
Expand Down Expand Up @@ -546,6 +563,16 @@ launchFromInterceptor
Boolean
=
false
private
val
allowRedirectUrls
:
Set
<
String
>
=
ALLOW_REDIRECT_HOSTS
)
:
RequestInterceptor
Expand Down Expand Up @@ -580,14 +607,18 @@ InterceptionResponse
?
{
val
uriScheme
encodedUri
=
Uri
.
parse
(
uri
)
val
uriScheme
=
encodedUri
.
scheme
val
Expand All @@ -600,6 +631,19 @@ contains
uriScheme
)
val
isAllowedRedirect
=
(
isRedirect
&
&
encodedUri
.
host
in
allowRedirectUrls
)
val
doNotIntercept
=
when
Expand All @@ -620,6 +664,7 @@ from
an
user
gesture
allowed
redirect
and
direct
Expand Down Expand Up @@ -653,7 +698,7 @@ hasUserGesture
&
&
!
isRedirect
isAllowedRedirect
&
&
!
Expand Down Expand Up @@ -933,4 +978,27 @@ uri
return
null
}
companion
object
{
internal
val
ALLOW_REDIRECT_HOSTS
:
Set
<
String
>
=
setOf
(
"
www
.
ubereats
.
com
"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,16 @@ true
useCases
=
mockUseCases
allowRedirectUrls
=
setOf
(
"
soundcloud
.
com
"
)
)
}
Test
Expand Down Expand Up @@ -562,7 +572,8 @@ request
is
intercepted
by
a
an
allowed
redirect
(
)
Expand Down Expand Up @@ -596,6 +607,40 @@ Test
fun
request
is
not
intercepted
by
a
not
allowed
redirect
(
)
{
val
response
=
appLinksInterceptor
.
onLoadRequest
(
mockEngineSession
webUrl
false
false
true
false
)
assertEquals
(
null
response
)
}
Test
fun
request
is
intercepted
by
direct
Expand Down

0 comments on commit 6277ab0

Please sign in to comment.