Chromium Code Reviews| Index: runtime/bin/extensions.cc |
| diff --git a/runtime/bin/extensions.cc b/runtime/bin/extensions.cc |
| index afcb29fdc52a10ba9222e1c0c63e68becdcad562..09f36b6c54bb95e18bf4be2d2b0d61c6693f916b 100644 |
| --- a/runtime/bin/extensions.cc |
| +++ b/runtime/bin/extensions.cc |
| @@ -10,27 +10,34 @@ |
| #include "platform/assert.h" |
| #include "platform/globals.h" |
| #include "bin/dartutils.h" |
| +#include "bin/file.h" |
| Dart_Handle Extensions::LoadExtension(const char* extension_url, |
| Dart_Handle parent_library) { |
| ASSERT(DartUtils::IsDartExtensionSchemeURL(extension_url)); |
| - const char* library_name = |
| + // Make a mutable copy of the extension url, without the "dart:" scheme. |
| + const char* path_component = |
| extension_url + strlen(DartUtils::kDartExtensionScheme); |
| - if (strchr(library_name, '/') != NULL || |
| - strchr(library_name, '\\') != NULL) { |
| - return Dart_Error("path components not allowed in extension library name"); |
| - } |
| - void* library_handle = LoadExtensionLibrary(library_name); |
| + const char* path_component_strings[2] = { path_component, NULL }; |
| + char* library_path = Concatenate(path_component_strings); |
|
Mads Ager (google)
2012/03/15 08:44:09
Instead of these two lines, please use strdup(path
Bill Hesse
2012/03/15 13:08:54
Done.
|
| + // Extract the path and the extension name from the url. |
| + char* last_path_separator = strrchr(library_path, File::PathSeparator()[0]); |
| + char* extension_name = last_path_separator + 1; |
| + *last_path_separator = '\0'; // Terminate library_path at last separator. |
| + |
| + void* library_handle = LoadExtensionLibrary(library_path, extension_name); |
| if (!library_handle) { |
| + free(library_path); |
| return Dart_Error("cannot find extension library"); |
| } |
| - const char* strings[3] = { library_name, "_Init", NULL }; |
| + const char* strings[3] = { extension_name, "_Init", NULL }; |
| char* init_function_name = Concatenate(strings); |
| typedef Dart_Handle (*InitFunctionType)(Dart_Handle import_map); |
| InitFunctionType fn = reinterpret_cast<InitFunctionType>( |
| ResolveSymbol(library_handle, init_function_name)); |
| free(init_function_name); |
| + free(library_path); |
| if (fn == NULL) { |
| return Dart_Error("cannot find initialization function in extension"); |