mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-26 19:28:59 +00:00
Ladybird/AppKit: Sanitize user-provided URLs with LibWebView
This commit is contained in:
parent
f023e37de7
commit
aa5cd24c90
Notes:
sideshowbarker
2024-07-17 02:37:08 +09:00
Author: https://github.com/trflynn89
Commit: aa5cd24c90
Pull-request: https://github.com/SerenityOS/serenity/pull/21435
Reviewed-by: https://github.com/ADKaster ✅
7 changed files with 58 additions and 95 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue