Skip to content

Commit 94e6ede

Browse files
committed
Stricter verification of URLs
1 parent 102747a commit 94e6ede

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

main.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,34 @@ function createWindow () {
2020
evt.preventDefault();
2121
});
2222

23-
win.webContents.on('new-window', function(e, url) {
24-
if (url.startsWith('https://identity.bitclout.com/')) {
25-
return;
26-
}
23+
win.webContents.on('will-navigate', function(event, url) {
24+
handleNavigate(win, event, url);
25+
});
2726

28-
e.preventDefault();
29-
shell.openExternal(url);
27+
win.webContents.on('new-window', function(event, url) {
28+
handleNavigate(win, event, url);
3029
});
3130
}
3231

32+
function handleNavigate(win, event, url) {
33+
win.setTitle(url);
34+
35+
// Allow bitclout-approved URLs
36+
if (url.startsWith('https://bitclout.com/') || url.startsWith('https://identity.bitclout.com/')) {
37+
return;
38+
}
39+
40+
event.preventDefault();
41+
42+
// Only allow URLs and emails
43+
if(!url.startsWith('https://') && !url.startsWith('http://') && !url.startsWith('mailto:')) {
44+
return;
45+
}
46+
47+
// Open https links in external browser
48+
shell.openExternal(url);
49+
}
50+
3351
app.whenReady().then(() => {
3452
createWindow()
3553

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "BitClout",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "bitclout.com electron app",
55
"main": "main.js",
66
"scripts": {

0 commit comments

Comments
 (0)