Skip to content

Commit

Permalink
Use / if installed in main folder
Browse files Browse the repository at this point in the history
Otherwise an empty string is used indicating the cookie is only valid for those resources. This can lead to eunexpected behaviour.

Fixes #19196
  • Loading branch information
LukasReschke committed Oct 6, 2015
1 parent 191f1b2 commit 6a4f22c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function __construct($appName, $urlParams = array()){
});

$this->registerService('OCP\\AppFramework\\Http\\IOutput', function($c){
return new Output();
return new Output($this->getServer()->getWebRoot());
});

$this->registerService('OCP\\IAvatarManager', function($c) {
Expand Down
16 changes: 13 additions & 3 deletions lib/private/appframework/http/output.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
* Very thin wrapper class to make output testable
*/
class Output implements IOutput {
/** @var string */
private $webRoot;

/**
* @param $webRoot
*/
public function __construct($webRoot) {
$this->webRoot = $webRoot;
}

/**
* @param string $out
Expand Down Expand Up @@ -72,10 +81,11 @@ public function getHttpResponseCode() {
* @param string $path
* @param string $domain
* @param bool $secure
* @param bool $httponly
* @param bool $httpOnly
*/
public function setCookie($name, $value, $expire, $path, $domain, $secure, $httponly) {
setcookie($name, $value, $expire, $path, $domain, $secure, $httponly);
public function setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly) {
$path = $this->webRoot ? : '/';
setcookie($name, $value, $expire, $path, $domain, $secure, $httpOnly);
}

}
4 changes: 2 additions & 2 deletions lib/public/appframework/http/ioutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public function setHttpResponseCode($code);
* @param string $path
* @param string $domain
* @param bool $secure
* @param bool $httponly
* @param bool $httpOnly
* @since 8.1.0
*/
public function setCookie($name, $value, $expire, $path, $domain, $secure, $httponly);
public function setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly);

}

0 comments on commit 6a4f22c

Please sign in to comment.