File tree 2 files changed +17
-3
lines changed
html_builder/static/src/website_preview
html_editor/static/src/main/link
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -191,7 +191,12 @@ export class WebsiteBuilder extends Component {
191
191
return ;
192
192
}
193
193
194
- if ( ! isHTTPSorNakedDomainRedirection ( iframe . contentWindow . location . origin , window . location . origin ) ) {
194
+ if (
195
+ ! isHTTPSorNakedDomainRedirection (
196
+ iframe . contentWindow . location . origin ,
197
+ window . location . origin
198
+ )
199
+ ) {
195
200
// If another domain ends up loading in the iframe (for example,
196
201
// if the iframe is being redirected and has no initial URL, so it
197
202
// loads "about:blank"), do not push that into the history
@@ -280,7 +285,14 @@ export class WebsiteBuilder extends Component {
280
285
if ( href && target !== "_blank" && ! this . state . isEditing ) {
281
286
if ( isTopWindowURL ( linkEl ) ) {
282
287
ev . preventDefault ( ) ;
283
- browser . location . assign ( href ) ;
288
+ try {
289
+ browser . location . assign ( href ) ;
290
+ } catch {
291
+ this . notification . add ( `"${ href } " ${ _t ( "is not a valid URL." ) } ` , {
292
+ title : _t ( "Invalid URL" ) ,
293
+ type : "danger" ,
294
+ } ) ;
295
+ }
284
296
} else if (
285
297
this . websiteContent . el . contentWindow . location . pathname !==
286
298
new URL ( href ) . pathname
Original file line number Diff line number Diff line change @@ -194,6 +194,9 @@ export class LinkPopover extends Component {
194
194
) {
195
195
url = "https://" + url ;
196
196
}
197
+ if ( url && ( url . startsWith ( "http:" ) || url . startsWith ( "https:" ) ) ) {
198
+ url = URL . parse ( url ) ? url : "" ;
199
+ }
197
200
return url ;
198
201
}
199
202
deduceUrl ( text ) {
@@ -228,7 +231,6 @@ export class LinkPopover extends Component {
228
231
this . state . previewIcon = { type : "mimetype" , value : mimetype } ;
229
232
return ;
230
233
}
231
-
232
234
try {
233
235
url = new URL ( this . state . url ) ; // relative to absolute
234
236
} catch {
You can’t perform that action at this time.
0 commit comments