1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:47:34 +00:00

Ladybird/AppKit: Sanitize user-provided URLs with LibWebView

This commit is contained in:
Timothy Flynn 2023-10-13 11:04:07 -04:00 committed by Tim Flynn
parent f023e37de7
commit aa5cd24c90
7 changed files with 58 additions and 95 deletions

View file

@ -5,6 +5,7 @@
*/
#include <LibWebView/History.h>
#include <LibWebView/URL.h>
#import <Application/ApplicationDelegate.h>
#import <LibWeb/Loader/ResourceLoader.h>
@ -13,7 +14,6 @@
#import <UI/Tab.h>
#import <UI/TabController.h>
#import <Utilities/Conversions.h>
#import <Utilities/URL.h>
#if !__has_feature(objc_arc)
# error "This project requires ARC"
@ -600,9 +600,11 @@ enum class IsHistoryNavigation {
return NO;
}
auto* url_string = [[text_view textStorage] string];
auto url = Ladybird::sanitize_url(url_string);
[self loadURL:url];
auto url_string = Ladybird::ns_string_to_string([[text_view textStorage] string]);
if (auto url = WebView::sanitize_url(url_string); url.has_value()) {
[self loadURL:*url];
}
[self.window makeFirstResponder:nil];
return YES;