Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit 300c6d6

Browse files
author
Aaron
authored
Merge pull request #1631 from sam-binary/xxs-attack
Xxs attack
2 parents 6474901 + d0276a2 commit 300c6d6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/indexPage/endpoint.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { get as getStorage, set as setStorage } from '../common/utils/storageManager';
22
import { generateWebSocketURL, getDefaultEndpoint, generateTestLiveApiInstance } from '../common/appId';
3+
import { translate } from '../common/utils/tools';
34

45
if (document.location.href.endsWith('/endpoint')) {
56
window.location.replace(`${document.location.href}.html`);
@@ -64,6 +65,15 @@ function addEndpoint(e) {
6465
setStorage('config.server_url', serverUrl);
6566
setStorage('config.app_id', appId);
6667

68+
const urlReg = /^(?:http(s)?:\/\/)?[\w.-]+(?:.[\w.-]+)+[\w-._~:\/?#[\]@!$&'()*+,;=.]+$/;
69+
70+
if (!urlReg.test(serverUrl)) {
71+
$('#error')
72+
.html(translate('Please enter a valid server URL'))
73+
.show();
74+
return;
75+
}
76+
6777
checkConnection(appId, serverUrl);
6878
}
6979

0 commit comments

Comments
 (0)