fix: do not enable node integration in child window if not enabled (#15108)
This commit is contained in:
		
					parent
					
						
							
								5cb50b0e33
							
						
					
				
			
			
				commit
				
					
						4a5d2117ba
					
				
			
		
					 3 changed files with 15 additions and 1 deletions
				
			
		|  | @ -331,6 +331,10 @@ void WebContentsPreferences::OverrideWebkitPrefs( | ||||||
|   std::string encoding; |   std::string encoding; | ||||||
|   if (dict_.GetString("defaultEncoding", &encoding)) |   if (dict_.GetString("defaultEncoding", &encoding)) | ||||||
|     prefs->default_encoding = encoding; |     prefs->default_encoding = encoding; | ||||||
|  | 
 | ||||||
|  |   bool node_integration = false; | ||||||
|  |   dict_.GetBoolean(options::kNodeIntegration, &node_integration); | ||||||
|  |   prefs->node_integration = node_integration; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool WebContentsPreferences::GetInteger(const base::StringPiece& attribute_name, | bool WebContentsPreferences::GetInteger(const base::StringPiece& attribute_name, | ||||||
|  |  | ||||||
|  | @ -16,6 +16,7 @@ | ||||||
| #include "atom/renderer/atom_render_frame_observer.h" | #include "atom/renderer/atom_render_frame_observer.h" | ||||||
| #include "atom/renderer/web_worker_observer.h" | #include "atom/renderer/web_worker_observer.h" | ||||||
| #include "base/command_line.h" | #include "base/command_line.h" | ||||||
|  | #include "content/public/common/web_preferences.h" | ||||||
| #include "content/public/renderer/render_frame.h" | #include "content/public/renderer/render_frame.h" | ||||||
| #include "native_mate/dictionary.h" | #include "native_mate/dictionary.h" | ||||||
| #include "third_party/WebKit/public/web/WebDocument.h" | #include "third_party/WebKit/public/web/WebDocument.h" | ||||||
|  | @ -86,6 +87,15 @@ void AtomRendererClient::DidCreateScriptContext( | ||||||
|   if (!render_frame->IsMainFrame() && !IsDevToolsExtension(render_frame)) |   if (!render_frame->IsMainFrame() && !IsDevToolsExtension(render_frame)) | ||||||
|     return; |     return; | ||||||
| 
 | 
 | ||||||
|  |   // Don't allow node integration if this is a child window and it does not have
 | ||||||
|  |   // node integration enabled.  Otherwise we would have memory leak in the child
 | ||||||
|  |   // window since we don't clean up node environments.
 | ||||||
|  |   //
 | ||||||
|  |   // TODO(zcbenz): We shouldn't allow node integration even for the top frame.
 | ||||||
|  |   if (!render_frame->GetWebkitPreferences().node_integration && | ||||||
|  |       render_frame->GetWebFrame()->Opener()) | ||||||
|  |     return; | ||||||
|  | 
 | ||||||
|   injected_frames_.insert(render_frame); |   injected_frames_.insert(render_frame); | ||||||
| 
 | 
 | ||||||
|   // Prepare the node bindings.
 |   // Prepare the node bindings.
 | ||||||
|  |  | ||||||
							
								
								
									
										2
									
								
								vendor/libchromiumcontent
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/libchromiumcontent
									
										
									
									
										vendored
									
									
								
							|  | @ -1 +1 @@ | ||||||
| Subproject commit 42e375e8b0bf4d7e030237adbb9cf7122d9f3246 | Subproject commit 73dcb51d27d18fc242279ae9ccf323bb304c93ae | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Cheng Zhao
				Cheng Zhao