Skip to content
This repository
Browse code

Merge branch 'master' into 2.3

Conflicts:
	lib/Cake/View/Helper.php
  • Loading branch information...
commit 739982addb8e38db9903adaf064496d888c21ce9 2 parents 869d556 + 1f35d82
Mark Story authored November 25, 2012
10  lib/Cake/Controller/CakeErrorController.php
@@ -52,14 +52,12 @@ class CakeErrorController extends AppController {
52 52
  */
53 53
 	public function __construct($request = null, $response = null) {
54 54
 		parent::__construct($request, $response);
55  
-		if (
56  
-			count(Router::extensions()) &&
57  
-			!array_key_exists('RequestHandler', $this->components) &&
58  
-			!in_array('RequestHandler', $this->components, true)
  55
+		$this->constructClasses();
  56
+		if (count(Router::extensions()) &&
  57
+			!$this->Components->attached('RequestHandler')
59 58
 		) {
60  
-			$this->components[] = 'RequestHandler';
  59
+			$this->RequestHandler = $this->Components->load('RequestHandler');
61 60
 		}
62  
-		$this->constructClasses();
63 61
 		if ($this->Components->enabled('Auth')) {
64 62
 			$this->Components->disable('Auth');
65 63
 		}
1  lib/Cake/Controller/Component/EmailComponent.php
@@ -288,6 +288,7 @@ public function initialize(Controller $controller) {
288 288
 	public function send($content = null, $template = null, $layout = null) {
289 289
 		$lib = new CakeEmail();
290 290
 		$lib->charset = $this->charset;
  291
+		$lib->headerCharset = $this->charset;
291 292
 
292 293
 		$lib->from($this->_formatAddresses((array)$this->from));
293 294
 		if (!empty($this->to)) {
3  lib/Cake/Test/Case/View/HelperTest.php
@@ -622,6 +622,9 @@ public function testAssetUrl() {
622 622
 		$result = $this->Helper->assetUrl('style', array('ext' => '.css'));
623 623
 		$this->assertEquals('style.css', $result);
624 624
 
  625
+		$result = $this->Helper->assetUrl('dir/sub dir/my image', array('ext' => '.jpg'));
  626
+		$this->assertEquals('dir/sub%20dir/my%20image.jpg', $result);
  627
+
625 628
 		$result = $this->Helper->assetUrl('foo.jpg?one=two&three=four');
626 629
 		$this->assertEquals('foo.jpg?one=two&three=four', $result);
627 630
 	}
66  lib/Cake/View/Helper.php
@@ -295,38 +295,54 @@ public function assetUrl($path, $options = array()) {
295 295
 		if (is_array($path)) {
296 296
 			return $this->url($path, !empty($options['fullBase']));
297 297
 		}
298  
-		if (strpos($path, '://') === false) {
299  
-			if (!array_key_exists('plugin', $options) || $options['plugin'] !== false) {
300  
-				list($plugin, $path) = $this->_View->pluginSplit($path, false);
301  
-			}
302  
-			if (!empty($options['pathPrefix']) && $path[0] !== '/') {
303  
-				$path = $options['pathPrefix'] . $path;
304  
-			}
305  
-			if (
306  
-				!empty($options['ext']) &&
307  
-				strpos($path, '?') === false &&
308  
-				substr($path, -strlen($options['ext'])) !== $options['ext']
309  
-			) {
310  
-				$path .= $options['ext'];
311  
-			}
312  
-			if (isset($plugin)) {
313  
-				$path = Inflector::underscore($plugin) . '/' . $path;
314  
-			}
315  
-			$path = h($this->assetTimestamp($this->webroot($path)));
  298
+		if (strpos($path, '://') !== false) {
  299
+			return $path;
  300
+		}
  301
+		if (!array_key_exists('plugin', $options) || $options['plugin'] !== false) {
  302
+			list($plugin, $path) = $this->_View->pluginSplit($path, false);
  303
+		}
  304
+		if (!empty($options['pathPrefix']) && $path[0] !== '/') {
  305
+			$path = $options['pathPrefix'] . $path;
  306
+		}
  307
+		if (
  308
+			!empty($options['ext']) &&
  309
+			strpos($path, '?') === false &&
  310
+			substr($path, -strlen($options['ext'])) !== $options['ext']
  311
+		) {
  312
+			$path .= $options['ext'];
  313
+		}
  314
+		if (isset($plugin)) {
  315
+			$path = Inflector::underscore($plugin) . '/' . $path;
  316
+		}
  317
+		$path = $this->_encodeUrl($this->assetTimestamp($this->webroot($path)));
316 318
 
317  
-			if (!empty($options['fullBase'])) {
318  
-				$base = $this->url('/', true);
319  
-				$len = strlen($this->request->webroot);
320  
-				if ($len) {
321  
-					$base = substr($base, 0, -$len);
322  
-				}
323  
-				$path = $base . $path;
  319
+		if (!empty($options['fullBase'])) {
  320
+			$base = $this->url('/', true);
  321
+			$len = strlen($this->request->webroot);
  322
+			if ($len) {
  323
+				$base = substr($base, 0, -$len);
324 324
 			}
  325
+			$path = $base . $path;
325 326
 		}
326 327
 		return $path;
327 328
 	}
328 329
 
329 330
 /**
  331
+ * Encodes a URL for use in HTML attributes.
  332
+ *
  333
+ * @param string $url The url to encode.
  334
+ * @return string The url encoded for both URL & HTML contexts.
  335
+ */
  336
+	protected function _encodeUrl($url) {
  337
+		$path = parse_url($url, PHP_URL_PATH);
  338
+		$encoded = implode('/', array_map(
  339
+			'rawurlencode',
  340
+			explode('/', $path)
  341
+		));
  342
+		return h(str_replace($path, $encoded, $url));
  343
+	}
  344
+
  345
+/**
330 346
  * Adds a timestamp to a file based resource based on the value of `Asset.timestamp` in
331 347
  * Configure.  If Asset.timestamp is true and debug > 0, or Asset.timestamp == 'force'
332 348
  * a timestamp will be added.

0 notes on commit 739982a

Please sign in to comment.
Something went wrong with that request. Please try again.