Index: libraries.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/libraries/libraries.module,v retrieving revision 1.16 diff -u -p -r1.16 libraries.module --- libraries.module 15 Dec 2010 21:09:52 -0000 1.16 +++ libraries.module 11 Jan 2011 18:55:14 -0000 @@ -415,20 +415,19 @@ function libraries_load_files($library) foreach (array('js', 'css') as $type) { if (!empty($library['files'][$type])) { foreach ($library['files'][$type] as $data => $options) { - // If the value is not an array, it's a filename and passed as first - // (and only) argument. - if (!is_array($options)) { - // Prepend the library path to the file name. - $data = "$path/$options"; - $options = NULL; - } - // In some cases, the first parameter ($data) is an array. Arrays can't - // be passed as keys in PHP, so we have to get $data from the value - // array. - if (is_numeric($data)) { + // If the data key is not empty, we assume it's an array containing + // JavaScript settings, so we pass it on as is. + if (!empty($options['data'])) { $data = $options['data']; unset($options['data']); } + // If the key contains characters not permitted for filenames, it is + // inline JavaScript or CSS. Otherwise, it is a filename and we prepend + // the library path. + elseif (!preg_match('@^[a-z0-9._-\/]+$@', $data)) { + $data = "$path/$data"; + } + // Apply the default group if the group isn't explicitly given. if (!isset($options['group'])) { $options['group'] = ($type == 'js') ? JS_DEFAULT : CSS_DEFAULT;