html.php.patch

Patch to introduce specialurlencode - Mark van der Velden -, 03/16/2009 11:11 am

Download (1.3 kB)

 
system/helpers/html.php (working copy)
50 50
	}
51 51

  
52 52
	/**
53
	 * Perform a html::specialchars() with additional URL specific encoding.
54
	 *  
55
	 * @param   string   string to convert
56
	 * @param   boolean  encode existing entities
57
	 * @return  string
58
	 */
59
	public static function specialurlencode($str, $double_encode = TRUE)
60
	{
61
		return str_replace(' ', '%20', html::specialchars($str, $double_encode));
62
	}
63
	
64
	/**
53 65
	 * Create HTML link anchors.
54 66
	 *
55 67
	 * @param   string  URL or URI string
......
80 92

  
81 93
		return
82 94
		// Parsed URL
83
		'<a href="'.html::specialchars($site_url, FALSE).'"'
95
		'<a href="'.html::specialurlencode($site_url, FALSE).'"'
84 96
		// Attributes empty? Use an empty string
85 97
		.(is_array($attributes) ? html::attributes($attributes) : '').'>'
86 98
		// Title empty? Use the parsed URL
......
100 112
	{
101 113
		return
102 114
		// Base URL + URI = full URL
103
		'<a href="'.html::specialchars(url::base(FALSE, $protocol).$file, FALSE).'"'
115
		'<a href="'.html::specialurlencode(url::base(FALSE, $protocol).$file, FALSE).'"'
104 116
		// Attributes empty? Use an empty string
105 117
		.(is_array($attributes) ? html::attributes($attributes) : '').'>'
106 118
		// Title empty? Use the filename part of the URI