Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add URL protocol validation #996

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions apps/browser-extension/src/NotConfiguredPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ export default function NotConfiguredPage() {
setError("Server address is required");
return;
}

// Add URL protocol validation
if (
!serverAddress.startsWith("http://") &&
!serverAddress.startsWith("https://")
) {
setError("Server address must start with http:// or https://");
return;
}

setSettings((s) => ({ ...s, address: serverAddress.replace(/\/$/, "") }));
navigate("/signin");
};
Expand Down
13 changes: 13 additions & 0 deletions apps/mobile/app/signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ export default function Signin() {
}

const onSignin = () => {
if (!formState.serverAddress) {
setError("Server address is required");
return;
}

if (
!formState.serverAddress.startsWith("http://") &&
!formState.serverAddress.startsWith("https://")
) {
setError("Server address must start with http:// or https://");
return;
}

if (loginType === LoginType.Password) {
const randStr = (Math.random() + 1).toString(36).substring(5);
login({
Expand Down