mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-31 13:20:59 +00:00 
			
		
		
		
	LibWeb: Don't reject worker scripts with a JavaScript MIME type
The condition for checking if a script has a JS MIME type is currently flipped. Extract the check to a local to make it a bit easier to reason about at quick glance.
This commit is contained in:
		
							parent
							
								
									50406f541b
								
							
						
					
					
						commit
						e1092aed3c
					
				
				
				Notes:
				
					sideshowbarker
				
				2024-07-17 05:03:11 +09:00 
				
			
			Author: https://github.com/trflynn89
Commit: e1092aed3c
Pull-request: https://github.com/SerenityOS/serenity/pull/21947
Reviewed-by: https://github.com/ADKaster ✅
			
					 1 changed files with 6 additions and 2 deletions
				
			
		|  | @ -380,8 +380,12 @@ WebIDL::ExceptionOr<void> fetch_classic_worker_script(AK::URL const& url, Enviro | |||
|         // - response's URL's scheme is an HTTP(S) scheme; and
 | ||||
|         // - the result of extracting a MIME type from response's header list is not a JavaScript MIME type,
 | ||||
|         auto maybe_mime_type = MUST(response->header_list()->extract_mime_type()); | ||||
|         if (response->url().has_value() && Fetch::Infrastructure::is_http_or_https_scheme(response->url()->scheme()) && (!maybe_mime_type.has_value() || maybe_mime_type->is_javascript())) { | ||||
|             dbgln("Invalid non-javascript mime type for worker script at {}", response->url().value()); | ||||
|         auto mime_type_is_javascript = maybe_mime_type.has_value() && maybe_mime_type->is_javascript(); | ||||
| 
 | ||||
|         if (response->url().has_value() && Fetch::Infrastructure::is_http_or_https_scheme(response->url()->scheme()) && !mime_type_is_javascript) { | ||||
|             auto mime_type_serialized = maybe_mime_type.has_value() ? MUST(maybe_mime_type->serialized()) : "unknown"_string; | ||||
|             dbgln("Invalid non-javascript mime type \"{}\" for worker script at {}", mime_type_serialized, response->url().value()); | ||||
| 
 | ||||
|             // then run onComplete given null, and abort these steps.
 | ||||
|             on_complete->function()(nullptr); | ||||
|             return; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy Flynn
						Timothy Flynn