From 502aebdc372a8c869507df23eec9ca643dc83e39 Mon Sep 17 00:00:00 2001 From: RainLoop Team Date: Fri, 14 Aug 2015 23:20:47 +0400 Subject: [PATCH] Fix cookie bug (#800) + small fixes --- gulpfile.js | 54 ++++++++++++------- package.json | 4 +- .../app/libraries/MailSo/Mail/MailClient.php | 5 +- .../0.0.0/app/libraries/RainLoop/Actions.php | 1 - .../v/0.0.0/app/libraries/RainLoop/Api.php | 2 +- .../libraries/RainLoop/Config/Application.php | 2 +- .../v/0.0.0/app/libraries/RainLoop/Utils.php | 8 ++- 7 files changed, 47 insertions(+), 29 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index e6ebe3b55..d4f3108b4 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -12,6 +12,8 @@ var releasesPath: 'build/dist/releases', community: true, watch: false, + watchInterval: 1000, + googleCompile: false, rainloopBuilded: false, destPath: '', @@ -81,11 +83,18 @@ function cleanDir(sDir) .pipe(require('gulp-rimraf')()); } -function renameFileWothMd5Hash(sFile) +function renameFileWithMd5Hash(sFile, callback) { var sHash = require('crypto').createHash('md5').update(fs.readFileSync(sFile)).digest('hex'); - fs.renameSync(sFile, sFile.replace(/\.zip$/, '-' + sHash + '.zip')); - return true; + cfg.lastMd5File = sFile.replace(/\.zip$/, '-' + sHash + '.zip'); + fs.renameSync(sFile, cfg.lastMd5File); + callback(); +} + +function copyFile(sFile, sNewFile, callback) +{ + fs.writeFileSync(sNewFile, fs.readFileSync(sFile)); + callback(); } cfg.paths.globjs = 'dev/**/*.js'; @@ -450,13 +459,13 @@ gulp.task('js:lint', function() { .pipe(jshint.reporter('jshint-summary', cfg.summary)) .pipe(jshint.reporter('fail')) // google compiler - .pipe(closureCompiler({ + .pipe(gulpif(cfg.googleCompile, closureCompiler({ compilerPath: './build/compiler.jar', fileName: 'gc.js', compilerFlags: { output_wrapper: '(function(){%output%}());' } - })); + }))) ; }); @@ -574,6 +583,7 @@ gulp.task('rainloop:setup', ['rainloop:copy'], function() { cfg.zipSrcPath = dist; cfg.zipFile = 'rainloop-' + (cfg.community ? 'community-' : '') + versionFull + '.zip'; cfg.md5File = cfg.zipFile; + cfg.lastMd5File = ''; cfg.rainloopBuilded = true; }); @@ -583,15 +593,19 @@ gulp.task('rainloop:zip', ['rainloop:copy', 'rainloop:setup'], function() { zipDir(cfg.zipSrcPath, cfg.destPath, cfg.zipFile) : false; }); -gulp.task('rainloop:md5', ['rainloop:zip'], function() { - return (cfg.destPath && cfg.md5File) ? - renameFileWothMd5Hash(cfg.destPath + cfg.md5File) : false; +gulp.task('rainloop:md5', ['rainloop:zip'], function(callback) { + renameFileWithMd5Hash(cfg.destPath + cfg.md5File, callback); }); gulp.task('rainloop:clean', ['rainloop:copy', 'rainloop:setup', 'rainloop:zip'], function() { return (cfg.cleanPath) ? cleanDir(cfg.cleanPath) : false; }); +gulp.task('rainloop:shortname', ['rainloop:md5'], function(callback) { + copyFile(cfg.lastMd5File, cfg.destPath + + 'rainloop' + (cfg.community ? '-community' : '') + '-latest.zip', callback); +}); + // BUILD (OwnCloud) gulp.task('rainloop:owncloud:copy', function() { @@ -657,15 +671,19 @@ gulp.task('rainloop:owncloud:zip', ['rainloop:owncloud:copy', 'rainloop:owncloud zipDir(cfg.zipSrcPath, cfg.destPath, cfg.zipFile) : false; }); -gulp.task('rainloop:owncloud:md5', ['rainloop:owncloud:zip'], function() { - return (cfg.destPath && cfg.md5File) ? - renameFileWothMd5Hash(cfg.destPath + cfg.md5File) : false; +gulp.task('rainloop:owncloud:md5', ['rainloop:owncloud:zip'], function(callback) { + renameFileWithMd5Hash(cfg.destPath + cfg.md5File, callback); }); gulp.task('rainloop:owncloud:clean', ['rainloop:owncloud:copy', 'rainloop:owncloud:setup', 'rainloop:owncloud:zip'], function() { return (cfg.cleanPath) ? cleanDir(cfg.cleanPath) : false; }); +gulp.task('rainloop:owncloud:shortname', ['rainloop:owncloud:md5'], function(callback) { + copyFile(cfg.lastMd5File, cfg.destPath + + 'rainloop' + (cfg.community ? '' : '-standard') + '.zip', callback); +}); + // MAIN gulp.task('default', ['js:libs', 'js:boot', 'js:openpgp', 'js:openpgpworker', 'js:min', 'css:main:min', 'ckeditor', 'fontastic']); gulp.task('fast-', ['js:app', 'js:admin', 'js:chunks', 'css:main']); @@ -675,14 +693,14 @@ gulp.task('fast+', ['package:community-off', 'fast-']); gulp.task('rainloop:start', ['js:lint', 'rainloop:copy', 'rainloop:setup']); -gulp.task('rainloop-', ['rainloop:start', 'rainloop:zip', 'rainloop:md5', 'rainloop:clean']); +gulp.task('rainloop-', ['rainloop:start', 'rainloop:zip', 'rainloop:md5', 'rainloop:clean', 'rainloop:shortname']); gulp.task('rainloop', ['package:community-on', 'rainloop-']); gulp.task('rainloop+', ['package:community-off', 'rainloop-']); gulp.task('owncloud-', ['rainloop:owncloud:copy', 'rainloop:owncloud:copy-rainloop', 'rainloop:owncloud:copy-rainloop:clean', - 'rainloop:owncloud:setup', 'rainloop:owncloud:zip', 'rainloop:owncloud:md5', 'rainloop:owncloud:clean']); + 'rainloop:owncloud:setup', 'rainloop:owncloud:zip', 'rainloop:owncloud:md5', 'rainloop:owncloud:clean', 'rainloop:owncloud:shortname']); gulp.task('owncloud', ['package:community-on', 'owncloud-']); gulp.task('owncloud+', ['package:community-off', 'owncloud-']); @@ -691,15 +709,15 @@ gulp.task('owncloud+', ['package:community-off', 'owncloud-']); gulp.task('watch', ['fast'], function() { cfg.watch = true; livereload.listen(); - gulp.watch(cfg.paths.globjs, {interval: 1000}, ['js:app', 'js:admin']); - gulp.watch(cfg.paths.less.main.watch, {interval: 1000}, ['css:main']); + gulp.watch(cfg.paths.globjs, {interval: cfg.watchInterval}, ['js:app', 'js:admin']); + gulp.watch(cfg.paths.less.main.watch, {interval: cfg.watchInterval}, ['css:main']); }); gulp.task('watch+', ['fast+'], function() { cfg.watch = true; livereload.listen(); - gulp.watch(cfg.paths.globjs, {interval: 1000}, ['js:app', 'js:admin']); - gulp.watch(cfg.paths.less.main.watch, {interval: 1000}, ['css:main']); + gulp.watch(cfg.paths.globjs, {interval: cfg.watchInterval}, ['js:app', 'js:admin']); + gulp.watch(cfg.paths.less.main.watch, {interval: cfg.watchInterval}, ['css:main']); }); // ALIASES @@ -719,4 +737,4 @@ gulp.task('o', ['owncloud']); gulp.task('o+', ['owncloud+']); gulp.task('h', ['js:lint']); -gulp.task('l', ['js:lint']); \ No newline at end of file +gulp.task('l', ['js:lint']); diff --git a/package.json b/package.json index b67041bde..e5df42537 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "RainLoop", "title": "RainLoop Webmail", "version": "1.9.2", - "release": "351", + "release": "353", "description": "Simple, modern & fast web-based email client", "homepage": "http://rainloop.net", "main": "gulpfile.js", @@ -40,7 +40,7 @@ "plugins" ], "readmeFilename": "README.md", - "ownCloudPackageVersion": "4.5", + "ownCloudPackageVersion": "4.6", "engines": { "node": ">= 0.10.0" }, diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php index 378f4b032..3e9de81cd 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php @@ -949,10 +949,7 @@ class MailClient } /** - * @param string $sSearch - * @param bool $bDetectGmail = true - * - * @return string + * @return bool */ public function IsGmail() { diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php index 88759c1b5..121449e04 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -1524,7 +1524,6 @@ class Actions $oSettings = $this->SettingsProvider()->Load($oAccount); - if (!$oAccount->IsAdditionalAccount() && !empty($aResult['WelcomePageUrl']) && ('once' === $aResult['WelcomePageDisplay'] || 'always' === $aResult['WelcomePageDisplay'])) { diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Api.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Api.php index 5680c1359..5da4ddac3 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Api.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Api.php @@ -108,7 +108,7 @@ class Api $sSslCafile = \RainLoop\Api::Config()->Get('ssl', 'cafile', ''); $sSslCapath = \RainLoop\Api::Config()->Get('ssl', 'capath', ''); - \RainLoop\Utils::$CookieDefaultPath = \RainLoop\Api::Config()->Get('labs', 'cookie_path', '/'); + \RainLoop\Utils::$CookieDefaultPath = \RainLoop\Api::Config()->Get('labs', 'cookie_default_path', ''); if (!empty($sSslCafile) || !empty($sSslCapath)) { diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php index 1282de2c9..19839bb5d 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php @@ -348,7 +348,7 @@ Enables caching in the system'), 'fast_cache_memcache_port' => array(11211), 'fast_cache_memcache_expire' => array(43200), 'use_local_proxy_for_external_images' => array(false), - 'cookie_path' => array('/'), + 'cookie_default_path' => array(''), 'startup_url' => array(''), 'emogrifier' => array(true), 'dev_email' => array(''), diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Utils.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Utils.php index 56a53082f..a4c587955 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Utils.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Utils.php @@ -7,7 +7,7 @@ class Utils /** * @var string */ - static $CookieDefaultPath = '/'; + static $CookieDefaultPath = ''; static $Cookies = null; @@ -518,6 +518,7 @@ class Utils if (null === $sPath) { $sPath = \RainLoop\Utils::$CookieDefaultPath; + $sPath = $sPath && 0 < \strlen($sPath) ? $sPath : null; } \RainLoop\Utils::$Cookies[$sName] = $sValue; @@ -531,8 +532,11 @@ class Utils \RainLoop\Utils::$Cookies = is_array($_COOKIE) ? $_COOKIE : array(); } + $sPath = \RainLoop\Utils::$CookieDefaultPath; + $sPath = $sPath && 0 < \strlen($sPath) ? $sPath : null; + unset(\RainLoop\Utils::$Cookies[$sName]); - @\setcookie($sName, '', \time() - 3600 * 24 * 30); + @\setcookie($sName, '', \time() - 3600 * 24 * 30, $sPath); } /**