diff options
author | Steve Clay <steve@mrclay.org> | 2012-04-10 09:51:20 -0400 |
---|---|---|
committer | Steve Clay <steve@mrclay.org> | 2012-04-10 09:51:20 -0400 |
commit | 6d4ac854d8f0a4480ffe16f2bd2a7861707074ee (patch) | |
tree | 5ef9a631f8acecf694065425edefd5ee78d45d1b /start.php | |
parent | cb27322b1421bd4cb2ce1889c38da5c8666d68f2 (diff) | |
download | elgg-6d4ac854d8f0a4480ffe16f2bd2a7861707074ee.tar.gz elgg-6d4ac854d8f0a4480ffe16f2bd2a7861707074ee.tar.bz2 |
Move URL preprocessing to hook
Diffstat (limited to 'start.php')
-rw-r--r-- | start.php | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -61,6 +61,9 @@ function videolist_init() { // register for embed elgg_register_plugin_hook_handler('embed_get_sections', 'all', 'videolist_embed_get_sections'); elgg_register_plugin_hook_handler('embed_get_items', 'videolist', 'videolist_embed_get_items'); + + // handle URLs without scheme + elgg_register_plugin_hook_handler('videolist:preprocess', 'url', 'videolist_preprocess_url'); // Register actions $actions_path = elgg_get_plugins_path() . "videolist/actions/videolist"; @@ -286,6 +289,26 @@ function videolist_icon_url_override($hook, $type, $returnvalue, $params) { } /** + * Prepend HTTP scheme if missing + * @param string $hook + * @param string $type + * @param string $returnvalue + * @param array $params + * @return string + */ +function videolist_preprocess_url($hook, $type, $returnvalue, $params) { + // undo get_input (htmlawed's) HTML-encoding + $returnvalue = str_replace('&', '&', $returnvalue); + + $parsed = parse_url($returnvalue); + if (empty($parsed['host']) && ! empty($parsed['path']) && $parsed['path'][0] !== '/') { + // user probably forgot scheme + $returnvalue = 'http://' . $returnvalue; + } + return $returnvalue; +} + +/** * Process upgrades for the videolist plugin */ function videolist_run_upgrades() { |