Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Briar Desktop
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
briar
Briar Desktop
Commits
26605a15
Commit
26605a15
authored
3 years ago
by
Sebastian
Browse files
Options
Downloads
Patches
Plain Diff
Check contact link validity more strictly
parent
46c61d9e
No related branches found
No related tags found
1 merge request
!109
Check contact link validity more strictly
Pipeline
#9265
passed
3 years ago
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/kotlin/org/briarproject/briar/desktop/contact/add/remote/AddContactViewModel.kt
+13
-10
13 additions, 10 deletions
...t/briar/desktop/contact/add/remote/AddContactViewModel.kt
with
13 additions
and
10 deletions
src/main/kotlin/org/briarproject/briar/desktop/contact/add/remote/AddContactViewModel.kt
+
13
−
10
View file @
26605a15
...
...
@@ -63,16 +63,23 @@ constructor(
}
private
fun
addPendingContact
(
link
:
String
,
alias
:
String
)
{
if
(
_handshakeLink
.
value
==
link
)
{
LOG
.
warn
{
"Please enter contact's link, not your own"
}
// TODO: show warning to user
return
}
if
(
remoteHandshakeLinkIsInvalid
(
link
))
{
// ignore preceding and trailing whitespace
val
matcher
=
HandshakeLinkConstants
.
LINK_REGEX
.
matcher
(
link
.
trim
())
// check if the link is well-formed
if
(!
matcher
.
matches
())
{
LOG
.
warn
{
"Remote handshake link is invalid"
}
// TODO: show message to user
return
}
// compare with own link
val
withoutSchema
=
matcher
.
group
(
2
)
val
withSchema
=
"briar://$withoutSchema"
if
(
_handshakeLink
.
value
==
withSchema
)
{
LOG
.
warn
{
"Please enter contact's link, not your own"
}
// TODO: show warning to user
return
}
if
(
aliasIsInvalid
(
alias
))
{
LOG
.
warn
{
"Alias is invalid"
}
// TODO: show message to user
...
...
@@ -106,10 +113,6 @@ constructor(
}
}
private
fun
remoteHandshakeLinkIsInvalid
(
link
:
String
):
Boolean
{
return
!
HandshakeLinkConstants
.
LINK_REGEX
.
matcher
(
link
).
find
()
}
private
fun
aliasIsInvalid
(
alias
:
String
):
Boolean
{
val
aliasUtf8
=
StringUtils
.
toUtf8
(
alias
)
return
aliasUtf8
.
isEmpty
()
||
aliasUtf8
.
size
>
AuthorConstants
.
MAX_AUTHOR_NAME_LENGTH
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment