Browse Source

Updating HttpSocket::serialize() to use Router::queryString(), updating Auth to use salted hashes, and resolving RequestHandler conflict for Ajax-based requests to custom content types

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4566 3807eeeb-6ff5-0310-8944-8be069107fe0
nate 19 years ago
parent
commit
5964d074c5

+ 1 - 1
cake/libs/controller/components/auth.php

@@ -671,7 +671,7 @@ class AuthComponent extends Object {
 		if (isset($controller->data[$this->userModel])) {
 			if (isset($controller->data[$this->userModel][$this->fields['username']]) && isset($controller->data[$this->userModel][$this->fields['password']])) {
 				$model =& $this->getUserModel();
-				$controller->data[$this->userModel][$this->fields['password']] = Security::hash($controller->data[$this->userModel][$this->fields['password']]);
+				$controller->data[$this->userModel][$this->fields['password']] = Security::hash(CAKE_SESSION_STRING . $controller->data[$this->userModel][$this->fields['password']]);
 			}
 		}
 	}

+ 12 - 13
cake/libs/controller/components/request_handler.php

@@ -195,23 +195,22 @@ class RequestHandlerComponent extends Object {
 		$this->setView($controller);
 		$controller->params['isAjax'] = $this->isAjax();
 
-		if (!empty($this->ext)) {
-			if (!in_array($this->ext, array('html', 'htm')) && in_array($this->ext, array_keys($this->__requestContent))) {
+		if (!empty($this->ext) && !in_array($this->ext, array('html', 'htm')) && in_array($this->ext, array_keys($this->__requestContent))) {
+			$controller->ext = '.ctp';
+			$controller->viewPath .= '/' . $this->ext;
+			$controller->layoutPath = $this->ext;
 
-				$controller->ext = '.ctp';
-				$controller->viewPath .= '/' . $this->ext;
-				$controller->layoutPath = $this->ext;
+			if (in_array($this->ext, array_keys($this->__requestContent))) {
+				$this->respondAs($this->ext);
+			}
 
-				if (in_array($this->ext, array_keys($this->__requestContent))) {
-					$this->respondAs($this->ext);
-				}
-
-				if (!in_array(ucfirst($this->ext), $controller->helpers)) {
-					if (file_exists(HELPERS . $this->ext . '.php') || fileExistsInPath(LIBS . 'view' . DS . 'helpers' . DS . $this->ext . '.php')) {
-						$controller->helpers[] = ucfirst($this->ext);
-					}
+			if (!in_array(ucfirst($this->ext), $controller->helpers)) {
+				if (file_exists(HELPERS . $this->ext . '.php') || fileExistsInPath(LIBS . 'view' . DS . 'helpers' . DS . $this->ext . '.php')) {
+					$controller->helpers[] = ucfirst($this->ext);
 				}
 			}
+		} else {
+			$this->setAjax($controller);
 		}
 
 		if ($this->requestedWith('xml')) {

+ 2 - 11
cake/libs/http_socket.php

@@ -363,17 +363,8 @@ class HttpSocket extends CakeSocket {
  * @todo Implement http_build_query for php5 and an alternative solution for php4, see http://us2.php.net/http_build_query
  */
 	function serialize($items) {
-		// Start a new array
-		$serializedItems = array();
-
-		// Loop through all $items to serialize
-		foreach ($items as $key => $value) {
-			// Urlencode them into the array of $serializedItems
-			$serializedItems[] = urlencode($key).'='.urlencode($value);
-		}
-		
-		// Glue the items together using the '&' separator and return the results
-		return join('&', $serializedItems);	
+		// Use the Router to serialize the data, stripping off the leading '?'
+		return substr(Router::queryString($items), 1);
 	}
 /**
  * Builds a HTTP header string for the given $options