File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,13 +36,17 @@ export default function Proxy() {
3636 const fullUrl = urlParam . startsWith ( "http" )
3737 ? urlParam
3838 : `https://${ urlParam } ` ;
39- new URL ( fullUrl ) ;
39+ const parsed = new URL ( fullUrl ) ;
40+ if ( parsed . protocol !== "http:" && parsed . protocol !== "https:" ) {
41+ navigate ( "/" ) ;
42+ return ;
43+ }
4044
4145 const tabId = generateTabId ( ) ;
4246 const newTab : ProxyTab = {
4347 id : tabId ,
44- url : fullUrl ,
45- domain : getDomain ( fullUrl ) ,
48+ url : parsed . toString ( ) ,
49+ domain : getDomain ( parsed . toString ( ) ) ,
4650 content : "" ,
4751 loading : true ,
4852 error : "" ,
@@ -159,13 +163,17 @@ export default function Proxy() {
159163 const fullUrl = urlInput . startsWith ( "http" )
160164 ? urlInput
161165 : `https://${ urlInput } ` ;
162- new URL ( fullUrl ) ;
166+ const parsed = new URL ( fullUrl ) ;
167+ if ( parsed . protocol !== "http:" && parsed . protocol !== "https:" ) {
168+ // Disallow potentially dangerous schemes like javascript:, data:, etc.
169+ return ;
170+ }
163171
164172 const tabId = generateTabId ( ) ;
165173 const newTab : ProxyTab = {
166174 id : tabId ,
167- url : fullUrl ,
168- domain : getDomain ( fullUrl ) ,
175+ url : parsed . toString ( ) ,
176+ domain : getDomain ( parsed . toString ( ) ) ,
169177 content : "" ,
170178 loading : true ,
171179 error : "" ,
You can’t perform that action at this time.
0 commit comments