aboutsummaryrefslogtreecommitdiff
path: root/start.php
diff options
context:
space:
mode:
authorSteve Clay <steve@mrclay.org>2012-04-10 09:51:20 -0400
committerSteve Clay <steve@mrclay.org>2012-04-10 09:51:20 -0400
commit6d4ac854d8f0a4480ffe16f2bd2a7861707074ee (patch)
tree5ef9a631f8acecf694065425edefd5ee78d45d1b /start.php
parentcb27322b1421bd4cb2ce1889c38da5c8666d68f2 (diff)
downloadelgg-6d4ac854d8f0a4480ffe16f2bd2a7861707074ee.tar.gz
elgg-6d4ac854d8f0a4480ffe16f2bd2a7861707074ee.tar.bz2
Move URL preprocessing to hook
Diffstat (limited to 'start.php')
-rw-r--r--start.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/start.php b/start.php
index bfb1796b9..f423b75ed 100644
--- a/start.php
+++ b/start.php
@@ -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('&amp;', '&', $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() {