| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 #include "bin/loader.h" | 6 #include "bin/loader.h" |
| 7 | 7 |
| 8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
| 9 #include "bin/dartutils.h" | 9 #include "bin/dartutils.h" |
| 10 #include "bin/extensions.h" | 10 #include "bin/extensions.h" |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 // Fall through | 289 // Fall through |
| 290 loader->error_ = Dart_NewUnhandledExceptionError(error); | 290 loader->error_ = Dart_NewUnhandledExceptionError(error); |
| 291 return false; | 291 return false; |
| 292 } | 292 } |
| 293 | 293 |
| 294 | 294 |
| 295 if (result->tag == _Dart_kImportExtension) { | 295 if (result->tag == _Dart_kImportExtension) { |
| 296 ASSERT(library_uri != Dart_Null()); | 296 ASSERT(library_uri != Dart_Null()); |
| 297 Dart_Handle library = Dart_LookupLibrary(library_uri); | 297 Dart_Handle library = Dart_LookupLibrary(library_uri); |
| 298 ASSERT(!Dart_IsError(library)); | 298 ASSERT(!Dart_IsError(library)); |
| 299 const char* lib_path_str = reinterpret_cast<const char*>(result->payload); | 299 const char* lib_uri = reinterpret_cast<const char*>(result->payload); |
| 300 if (strncmp(lib_uri, "http://", 7) == 0 || |
| 301 strncmp(lib_uri, "https://", 8) == 0) { |
| 302 loader->error_ = |
| 303 Dart_NewApiError("Cannot load native extensions over http: or https:"); |
| 304 return false; |
| 305 } |
| 300 const char* extension_uri = reinterpret_cast<const char*>(result->uri); | 306 const char* extension_uri = reinterpret_cast<const char*>(result->uri); |
| 307 const char* lib_path = DartUtils::RemoveScheme(lib_uri); |
| 301 const char* extension_path = DartUtils::RemoveScheme(extension_uri); | 308 const char* extension_path = DartUtils::RemoveScheme(extension_uri); |
| 302 if (strchr(extension_path, '/') != NULL || | 309 if (strchr(extension_path, '/') != NULL || |
| 303 (IsWindowsHost() && strchr(extension_path, '\\') != NULL)) { | 310 (IsWindowsHost() && strchr(extension_path, '\\') != NULL)) { |
| 304 loader->error_ = DartUtils::NewError( | 311 loader->error_ = DartUtils::NewError( |
| 305 "Relative paths for dart extensions are not supported: '%s'", | 312 "Relative paths for dart extensions are not supported: '%s'", |
| 306 extension_path); | 313 extension_path); |
| 307 return false; | 314 return false; |
| 308 } | 315 } |
| 309 Dart_Handle result = Extensions::LoadExtension(lib_path_str, | 316 Dart_Handle result = Extensions::LoadExtension(lib_path, |
| 310 extension_path, | 317 extension_path, |
| 311 library); | 318 library); |
| 312 if (Dart_IsError(result)) { | 319 if (Dart_IsError(result)) { |
| 313 loader->error_ = result; | 320 loader->error_ = result; |
| 314 return false; | 321 return false; |
| 315 } | 322 } |
| 316 return true; | 323 return true; |
| 317 } | 324 } |
| 318 | 325 |
| 319 // Check for payload and load accordingly. | 326 // Check for payload and load accordingly. |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 MutexLocker ml(loader_infos_lock_); | 743 MutexLocker ml(loader_infos_lock_); |
| 737 Loader* loader = LoaderForLocked(dest_port_id); | 744 Loader* loader = LoaderForLocked(dest_port_id); |
| 738 if (loader == NULL) { | 745 if (loader == NULL) { |
| 739 return; | 746 return; |
| 740 } | 747 } |
| 741 loader->QueueMessage(message); | 748 loader->QueueMessage(message); |
| 742 } | 749 } |
| 743 | 750 |
| 744 } // namespace bin | 751 } // namespace bin |
| 745 } // namespace dart | 752 } // namespace dart |
| OLD | NEW |