From c42097adf3b46c5c01c4952186a55c475f6da155 Mon Sep 17 00:00:00 2001 From: ozhozh Date: Sat, 29 Sep 2012 19:59:20 +0000 Subject: [PATCH] Allow filtering in URL sanitization. Fixes issue 1194. git-svn-id: http://yourls.googlecode.com/svn/trunk@766 12232710-3e20-11de-b438-597f59cd7555 --- includes/functions-formatting.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/functions-formatting.php b/includes/functions-formatting.php index de15526..ff58e00 100644 --- a/includes/functions-formatting.php +++ b/includes/functions-formatting.php @@ -65,12 +65,12 @@ function yourls_sanitize_title( $title ) { } // A few sanity checks on the URL -function yourls_sanitize_url( $url, $force_protocol = true, $force_lowercase = true ) { +function yourls_sanitize_url( $unsafe_url, $force_protocol = true, $force_lowercase = true ) { // make sure there's only one 'http://' at the beginning (prevents pasting a URL right after the default 'http://') $url = str_replace( array( 'http://http://', 'http://https://' ), array( 'http://', 'https://' ), - $url + $unsafe_url ); if( $force_protocol ) { @@ -88,7 +88,9 @@ function yourls_sanitize_url( $url, $force_protocol = true, $force_lowercase = t // clean and shave $url = yourls_clean_url( $url ); - return substr( $url, 0, 1999 ); + $url = substr( $url, 0, 1999 ); + + return yourls_apply_filter( 'sanitize_url', $url, $unsafe_url, $force_protocol, $force_lowercase ); } // Function to filter all invalid characters from a URL. Stolen from WP's clean_url() -- 2.45.0