aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files/css/files.css8
-rw-r--r--apps/files_versions/ajax/getVersions.php2
-rw-r--r--apps/files_versions/ajax/rollbackVersion.php1
-rw-r--r--core/command/db/converttype.php4
-rw-r--r--core/img/actions/shared.pngbin290 -> 264 bytes
-rw-r--r--core/img/actions/shared.svg7
-rw-r--r--lib/private/db/mdb2schemamanager.php16
-rw-r--r--lib/private/db/mdb2schemawriter.php14
-rw-r--r--lib/private/db/migrator.php12
-rw-r--r--lib/private/db/pgsqltools.php15
-rw-r--r--lib/private/db/sqlitemigrator.php16
-rw-r--r--lib/private/files/cache/cache.php2
-rw-r--r--lib/private/files/cache/scanner.php4
-rw-r--r--lib/private/files/cache/wrapper/cachejail.php2
-rw-r--r--lib/private/helper.php10
-rw-r--r--lib/private/memcache/factory.php4
-rw-r--r--lib/private/memcache/null.php35
-rw-r--r--settings/js/personal.js4
-rw-r--r--tests/lib/db/migrator.php2
-rw-r--r--tests/lib/files/cache/cache.php36
-rw-r--r--tests/lib/streamwrappers.php17
21 files changed, 153 insertions, 58 deletions
diff --git a/apps/files/css/files.css b/apps/files/css/files.css
index 1e7b1d45f71..5b947fa326c 100644
--- a/apps/files/css/files.css
+++ b/apps/files/css/files.css
@@ -261,10 +261,14 @@ table td.filename .thumbnail {
}
table td.filename input.filename {
width: 70%;
- margin-top: 1px;
- margin-left: 48px;
+ margin-top: 9px;
+ margin-left: 8px;
cursor: text;
}
+.has-favorites table td.filename input.filename {
+ margin-left: 52px;
+}
+
table td.filename a, table td.login, table td.logout, table td.download, table td.upload, table td.create, table td.delete { padding:3px 8px 8px 3px; }
table td.filename .nametext, .uploadtext, .modified, .column-last>span:first-child { float:left; padding:15px 0; }
diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php
index 4cc1c428898..80786433e7a 100644
--- a/apps/files_versions/ajax/getVersions.php
+++ b/apps/files_versions/ajax/getVersions.php
@@ -1,4 +1,6 @@
<?php
+OCP\JSON::checkLoggedIn();
+OCP\JSON::callCheck();
OCP\JSON::checkAppEnabled('files_versions');
$source = $_GET['source'];
diff --git a/apps/files_versions/ajax/rollbackVersion.php b/apps/files_versions/ajax/rollbackVersion.php
index e6133507738..326d8db74f7 100644
--- a/apps/files_versions/ajax/rollbackVersion.php
+++ b/apps/files_versions/ajax/rollbackVersion.php
@@ -1,5 +1,6 @@
<?php
+OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('files_versions');
OCP\JSON::callCheck();
diff --git a/core/command/db/converttype.php b/core/command/db/converttype.php
index 617910b3a90..8d1560b0511 100644
--- a/core/command/db/converttype.php
+++ b/core/command/db/converttype.php
@@ -228,6 +228,8 @@ class ConvertType extends Command {
}
protected function getTables(Connection $db) {
+ $db->getConfiguration()->
+ setFilterSchemaAssetsExpression('/^'.$this->config->getSystemValue('dbtableprefix', 'oc_').'/');
return $db->getSchemaManager()->listTableNames();
}
@@ -264,7 +266,7 @@ class ConvertType extends Command {
$this->copyTable($fromDB, $toDB, $table, $input, $output);
}
if ($input->getArgument('type') === 'pgsql') {
- $tools = new \OC\DB\PgSqlTools;
+ $tools = new \OC\DB\PgSqlTools($this->config);
$tools->resynchronizeDatabaseSequences($toDB);
}
// save new database config
diff --git a/core/img/actions/shared.png b/core/img/actions/shared.png
index 83ec1a0cf15..fdacbbabebc 100644
--- a/core/img/actions/shared.png
+++ b/core/img/actions/shared.png
Binary files differ
diff --git a/core/img/actions/shared.svg b/core/img/actions/shared.svg
index 60b54015167..d67d35c6e56 100644
--- a/core/img/actions/shared.svg
+++ b/core/img/actions/shared.svg
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="16" width="16" version="1.0" xmlns:cc="http://creativecommons.org/ns#" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/">
- <rect style="color:#000000" fill-opacity="0" height="97.986" width="163.31" y="-32.993" x="-62.897"/>
- <path style="block-progression:tb;color:#000000;text-transform:none;text-indent:0" d="m4.5689 2.4831c-0.96481 0-1.7833 0.70559-1.7833 1.6162 0.00685 0.28781 0.032588 0.64272 0.20434 1.3933v0.018581l0.018574 0.018573c0.055135 0.15793 0.13537 0.24827 0.24149 0.37154 0.10612 0.12326 0.23263 0.26834 0.35294 0.39011 0.014154 0.014326 0.023227 0.023201 0.037149 0.037163 0.023859 0.10383 0.052763 0.21557 0.074304 0.3158 0.057317 0.26668 0.051439 0.45553 0.037155 0.52015-0.4146 0.1454-0.9304 0.3187-1.3932 0.5199-0.2598 0.113-0.4949 0.2139-0.6873 0.3344-0.1923 0.1206-0.3836 0.2116-0.4458 0.483-0.0007972 0.012367-0.0007972 0.024787 0 0.037163-0.060756 0.55788-0.15266 1.3783-0.22291 1.932-0.015166 0.11656 0.046264 0.23943 0.14861 0.29723 0.84033 0.45393 2.1312 0.63663 3.418 0.63161 1.2868-0.005 2.5674-0.19845 3.3808-0.63161 0.10234-0.0578 0.16378-0.18067 0.14861-0.29723-0.0224-0.173-0.05-0.5633-0.0743-0.9474-0.0243-0.384-0.0454-0.7617-0.0743-0.9845-0.0101-0.0552-0.0362-0.1074-0.0743-0.1486-0.2584-0.3086-0.6445-0.4973-1.096-0.6874-0.4122-0.1735-0.8954-0.3538-1.3746-0.5573-0.02682-0.059748-0.053461-0.23358 0-0.50157 0.014356-0.071959 0.036836-0.14903 0.055729-0.22292 0.045032-0.05044 0.080132-0.091658 0.13003-0.14861 0.1064-0.1215 0.2207-0.2489 0.3157-0.3715 0.0951-0.1226 0.1728-0.2279 0.223-0.3715l0.018574-0.018581c0.1941-0.7837 0.1942-1.1107 0.2043-1.3933v-0.018573c0-0.91058-0.81848-1.6162-1.7833-1.6162zm5.101-1.4831c-1.4067 0-2.6 1.0287-2.6 2.3562 0.00998 0.4196 0.047512 0.93701 0.29791 2.0312v0.027083l0.027081 0.027083c0.080384 0.23025 0.19736 0.36196 0.35208 0.54166s0.33917 0.39121 0.51458 0.56874c0.020637 0.020887 0.033864 0.033826 0.054161 0.054175 0.034785 0.15137 0.076926 0.31428 0.10833 0.46041 0.083566 0.38879 0.074995 0.66411 0.054171 0.75832-0.6045 0.2122-1.3565 0.465-2.0312 0.7583-0.3789 0.1647-0.7217 0.3118-1.0021 0.4875-0.28044 0.17574-0.55934 0.30851-0.64999 0.70416-0.00116 0.01804-0.00116 0.03613 0 0.05418-0.08858 0.81334-0.22257 2.0094-0.325 2.8166-0.022111 0.16993 0.067452 0.34906 0.21666 0.43333 1.2252 0.66179 3.1072 0.92814 4.9833 0.92082 1.8761-0.0073 3.7431-0.28932 4.9291-0.92082 0.14921-0.08427 0.23878-0.2634 0.21666-0.43333-0.0327-0.25234-0.07287-0.82136-0.10833-1.3812-0.03546-0.55988-0.06625-1.1106-0.10833-1.4354-0.01468-0.0805-0.05274-0.15661-0.10833-0.21666-0.377-0.4498-0.94-0.7248-1.598-1.002-0.601-0.253-1.306-0.5158-2.004-0.8125-0.0391-0.087106-0.07795-0.34054 0-0.73124 0.02093-0.10491 0.05371-0.21727 0.08125-0.325 0.06566-0.073537 0.11683-0.13363 0.18958-0.21666 0.15516-0.17709 0.32189-0.36287 0.46041-0.54166s0.25186-0.33217 0.325-0.54166l0.02708-0.027083c0.28309-1.1425 0.28324-1.6193 0.29792-2.0312v-0.027083c0-1.3275-1.1933-2.3562-2.6-2.3562z"/>
+<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="16" width="16" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <g transform="translate(0 -1036.4)">
+ <path d="m12.228 1037.4c-1.3565 0-2.4592 1.0977-2.4592 2.4542 0 0.075 0.0084 0.1504 0.0149 0.2236l-4.7346 2.4145c-0.4291-0.3667-0.98611-0.5863-1.5947-0.5863-1.3565 0-2.4542 1.0977-2.4542 2.4543 0 1.3565 1.0977 2.4542 2.4542 2.4542 0.54607 0 1.0528-0.1755 1.4606-0.477l4.8637 2.4741c-0.0024 0.044-0.0099 0.089-0.0099 0.1342 0 1.3565 1.1027 2.4542 2.4592 2.4542s2.4542-1.0977 2.4542-2.4542-1.0977-2.4592-2.4542-2.4592c-0.63653 0-1.218 0.2437-1.6544 0.6409l-4.6953-2.4c0.01892-0.1228 0.03478-0.2494 0.03478-0.3775 0-0.072-0.0089-0.1437-0.0149-0.2137l4.7395-2.4145c0.42802 0.3627 0.98488 0.5813 1.5898 0.5813 1.3565 0 2.4542-1.1027 2.4542-2.4592s-1.0977-2.4542-2.4542-2.4542z"/>
+ </g>
</svg>
diff --git a/lib/private/db/mdb2schemamanager.php b/lib/private/db/mdb2schemamanager.php
index 78267094d0e..358360d0b46 100644
--- a/lib/private/db/mdb2schemamanager.php
+++ b/lib/private/db/mdb2schemamanager.php
@@ -36,9 +36,7 @@ class MDB2SchemaManager {
* TODO: write more documentation
*/
public function getDbStructure($file, $mode = MDB2_SCHEMA_DUMP_STRUCTURE) {
- $sm = $this->conn->getSchemaManager();
-
- return \OC_DB_MDB2SchemaWriter::saveSchemaToFile($file, $sm);
+ return \OC_DB_MDB2SchemaWriter::saveSchemaToFile($file, $this->conn);
}
/**
@@ -60,19 +58,19 @@ class MDB2SchemaManager {
public function getMigrator() {
$random = \OC::$server->getSecureRandom()->getMediumStrengthGenerator();
$platform = $this->conn->getDatabasePlatform();
+ $config = \OC::$server->getConfig();
if ($platform instanceof SqlitePlatform) {
- $config = \OC::$server->getConfig();
return new SQLiteMigrator($this->conn, $random, $config);
} else if ($platform instanceof OraclePlatform) {
- return new OracleMigrator($this->conn, $random);
+ return new OracleMigrator($this->conn, $random, $config);
} else if ($platform instanceof MySqlPlatform) {
- return new MySQLMigrator($this->conn, $random);
+ return new MySQLMigrator($this->conn, $random, $config);
} else if ($platform instanceof SQLServerPlatform) {
- return new MsSqlMigrator($this->conn, $random);
+ return new MsSqlMigrator($this->conn, $random, $config);
} else if ($platform instanceof PostgreSqlPlatform) {
- return new Migrator($this->conn, $random);
+ return new Migrator($this->conn, $random, $config);
} else {
- return new NoCheckMigrator($this->conn, $random);
+ return new NoCheckMigrator($this->conn, $random, $config);
}
}
diff --git a/lib/private/db/mdb2schemawriter.php b/lib/private/db/mdb2schemawriter.php
index a2a62a81475..a42cd86ba54 100644
--- a/lib/private/db/mdb2schemawriter.php
+++ b/lib/private/db/mdb2schemawriter.php
@@ -10,16 +10,22 @@ class OC_DB_MDB2SchemaWriter {
/**
* @param string $file
- * @param \Doctrine\DBAL\Schema\AbstractSchemaManager $sm
+ * @param \OC\DB\Connection $conn
* @return bool
*/
- static public function saveSchemaToFile($file, $sm) {
+ static public function saveSchemaToFile($file, \OC\DB\Connection $conn) {
+ $config = \OC::$server->getConfig();
+
$xml = new SimpleXMLElement('<database/>');
- $xml->addChild('name', OC_Config::getValue( "dbname", "owncloud" ));
+ $xml->addChild('name', $config->getSystemValue('dbname', 'owncloud'));
$xml->addChild('create', 'true');
$xml->addChild('overwrite', 'false');
$xml->addChild('charset', 'utf8');
- foreach ($sm->listTables() as $table) {
+
+ $conn->getConfiguration()->
+ setFilterSchemaAssetsExpression('/^' . $config->getSystemValue('dbtableprefix', 'oc_') . '/');
+
+ foreach ($conn->getSchemaManager()->listTables() as $table) {
self::saveTable($table, $xml->addChild('table'));
}
file_put_contents($file, $xml->asXML());
diff --git a/lib/private/db/migrator.php b/lib/private/db/migrator.php
index 31c648a9b65..8ccc02e36a5 100644
--- a/lib/private/db/migrator.php
+++ b/lib/private/db/migrator.php
@@ -14,6 +14,7 @@ use \Doctrine\DBAL\Schema\Table;
use \Doctrine\DBAL\Schema\Schema;
use \Doctrine\DBAL\Schema\SchemaConfig;
use \Doctrine\DBAL\Schema\Comparator;
+use OCP\IConfig;
use OCP\Security\ISecureRandom;
class Migrator {
@@ -28,13 +29,18 @@ class Migrator {
*/
private $random;
+ /** @var IConfig */
+ protected $config;
+
/**
* @param \Doctrine\DBAL\Connection $connection
* @param ISecureRandom $random
+ * @param IConfig $config
*/
- public function __construct(\Doctrine\DBAL\Connection $connection, ISecureRandom $random) {
+ public function __construct(\Doctrine\DBAL\Connection $connection, ISecureRandom $random, IConfig $config) {
$this->connection = $connection;
$this->random = $random;
+ $this->config = $config;
}
/**
@@ -70,6 +76,8 @@ class Migrator {
*/
$tables = $targetSchema->getTables();
+ $this->connection->getConfiguration()->
+ setFilterSchemaAssetsExpression('/^' . $this->config->getSystemValue('dbtableprefix', 'oc_') . '/');
$existingTables = $this->connection->getSchemaManager()->listTableNames();
foreach ($tables as $table) {
@@ -153,6 +161,8 @@ class Migrator {
}
protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
+ $connection->getConfiguration()->
+ setFilterSchemaAssetsExpression('/^' . $this->config->getSystemValue('dbtableprefix', 'oc_') . '/');
$sourceSchema = $connection->getSchemaManager()->createSchema();
// remove tables we don't know about
diff --git a/lib/private/db/pgsqltools.php b/lib/private/db/pgsqltools.php
index c3ac140594d..f3204d4c7b6 100644
--- a/lib/private/db/pgsqltools.php
+++ b/lib/private/db/pgsqltools.php
@@ -8,11 +8,23 @@
*/
namespace OC\DB;
+use OCP\IConfig;
/**
* Various PostgreSQL specific helper functions.
*/
class PgSqlTools {
+
+ /** @var \OCP\IConfig */
+ private $config;
+
+ /**
+ * @param \OCP\IConfig $config
+ */
+ public function __construct(IConfig $config) {
+ $this->config = $config;
+ }
+
/**
* @brief Resynchronizes all sequences of a database after using INSERTs
* without leaving out the auto-incremented column.
@@ -21,6 +33,9 @@ class PgSqlTools {
*/
public function resynchronizeDatabaseSequences(Connection $conn) {
$databaseName = $conn->getDatabase();
+ $conn->getConfiguration()->
+ setFilterSchemaAssetsExpression('/^' . $this->config->getSystemValue('dbtableprefix', 'oc_') . '/');
+
foreach ($conn->getSchemaManager()->listSequences() as $sequence) {
$sequenceName = $sequence->getName();
$sqlInfo = 'SELECT table_schema, table_name, column_name
diff --git a/lib/private/db/sqlitemigrator.php b/lib/private/db/sqlitemigrator.php
index 848e4986571..42b65634645 100644
--- a/lib/private/db/sqlitemigrator.php
+++ b/lib/private/db/sqlitemigrator.php
@@ -10,26 +10,10 @@ namespace OC\DB;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\Schema;
-use OCP\Security\ISecureRandom;
class SQLiteMigrator extends Migrator {
/**
- * @var \OCP\IConfig
- */
- private $config;
-
- /**
- * @param \Doctrine\DBAL\Connection $connection
- * @param ISecureRandom $random
- * @param \OCP\IConfig $config
- */
- public function __construct(\Doctrine\DBAL\Connection $connection, ISecureRandom $random, \OCP\IConfig $config) {
- parent::__construct($connection, $random);
- $this->config = $config;
- }
-
- /**
* @param \Doctrine\DBAL\Schema\Schema $targetSchema
* @throws \OC\DB\MigrationException
*
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index 9df64db7f07..bf44cf48aa7 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -699,6 +699,6 @@ class Cache {
*/
public function normalize($path) {
- return \OC_Util::normalizeUnicode($path);
+ return trim(\OC_Util::normalizeUnicode($path), '/');
}
}
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index a5383cee10d..d24b7459851 100644
--- a/lib/private/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
@@ -216,7 +216,7 @@ class Scanner extends BasicEmitter {
*/
public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1) {
if ($reuse === -1) {
- $reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : 0;
+ $reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG;
}
$data = $this->scanFile($path, $reuse);
if ($data !== null) {
@@ -247,7 +247,7 @@ class Scanner extends BasicEmitter {
*/
public function scanChildren($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1) {
if ($reuse === -1) {
- $reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : 0;
+ $reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG;
}
$this->emit('\OC\Files\Cache\Scanner', 'scanFolder', array($path, $this->storageId));
$size = 0;
diff --git a/lib/private/files/cache/wrapper/cachejail.php b/lib/private/files/cache/wrapper/cachejail.php
index f4ffc67d76a..3f7ea66ea1b 100644
--- a/lib/private/files/cache/wrapper/cachejail.php
+++ b/lib/private/files/cache/wrapper/cachejail.php
@@ -30,7 +30,7 @@ class CacheJail extends CacheWrapper {
if ($path === '') {
return $this->root;
} else {
- return $this->root . '/' . $path;
+ return $this->root . '/' . ltrim($path, '/');
}
}
diff --git a/lib/private/helper.php b/lib/private/helper.php
index 8e9b7d3b6f3..86cc0850bc3 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -882,13 +882,19 @@ class OC_Helper {
* @return null|string
*/
public static function findBinaryPath($program) {
+ $memcache = \OC::$server->getMemCacheFactory()->create('findBinaryPath');
+ if ($memcache->hasKey($program)) {
+ return $memcache->get($program);
+ }
+ $result = null;
if (!\OC_Util::runningOnWindows() && self::is_function_enabled('exec')) {
exec('command -v ' . escapeshellarg($program) . ' 2> /dev/null', $output, $returnCode);
if ($returnCode === 0 && count($output) > 0) {
- return escapeshellcmd($output[0]);
+ $result = escapeshellcmd($output[0]);
}
}
- return null;
+ $memcache->set($program, $result, 3600);
+ return $result;
}
/**
diff --git a/lib/private/memcache/factory.php b/lib/private/memcache/factory.php
index dba9e8a0e00..1e663eecfe1 100644
--- a/lib/private/memcache/factory.php
+++ b/lib/private/memcache/factory.php
@@ -24,7 +24,7 @@ class Factory implements ICacheFactory {
}
/**
- * get a cache instance, will return null if no backend is available
+ * get a cache instance, or Null backend if no backend available
*
* @param string $prefix
* @return \OC\Memcache\Cache
@@ -42,7 +42,7 @@ class Factory implements ICacheFactory {
} elseif (Memcached::isAvailable()) {
return new Memcached($prefix);
} else {
- return null;
+ return new Null($prefix);
}
}
diff --git a/lib/private/memcache/null.php b/lib/private/memcache/null.php
new file mode 100644
index 00000000000..62cd060aaca
--- /dev/null
+++ b/lib/private/memcache/null.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Copyright (c) 2015 Robin McCorkell <rmccorkell@karoshi.org.uk>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Memcache;
+
+class Null extends Cache {
+ public function get($key) {
+ return null;
+ }
+
+ public function set($key, $value, $ttl = 0) {
+ return true;
+ }
+
+ public function hasKey($key) {
+ return false;
+ }
+
+ public function remove($key) {
+ return true;
+ }
+
+ public function clear($prefix = '') {
+ return true;
+ }
+
+ static public function isAvailable() {
+ return true;
+ }
+}
diff --git a/settings/js/personal.js b/settings/js/personal.js
index fba4af1fd48..0cf0cd81a7b 100644
--- a/settings/js/personal.js
+++ b/settings/js/personal.js
@@ -168,7 +168,9 @@ function avatarResponseHandler (data) {
}
$(document).ready(function () {
- $('#pass2').showPassword().keyup();
+ if($('#pass2').length) {
+ $('#pass2').showPassword().keyup();
+ }
$("#passwordbutton").click(function () {
if ($('#pass1').val() !== '' && $('#pass2').val() !== '') {
// Serialize the data
diff --git a/tests/lib/db/migrator.php b/tests/lib/db/migrator.php
index 1a1d530f1d2..54267740480 100644
--- a/tests/lib/db/migrator.php
+++ b/tests/lib/db/migrator.php
@@ -39,7 +39,7 @@ class Migrator extends \Test\TestCase {
$this->markTestSkipped('DB migration tests are not supported on MSSQL');
}
$this->manager = new \OC\DB\MDB2SchemaManager($this->connection);
- $this->tableName = strtolower($this->getUniqueID('test_'));
+ $this->tableName = strtolower($this->getUniqueID('oc_test_'));
}
protected function tearDown() {
diff --git a/tests/lib/files/cache/cache.php b/tests/lib/files/cache/cache.php
index 81d7f3ce0bc..6df98ee531d 100644
--- a/tests/lib/files/cache/cache.php
+++ b/tests/lib/files/cache/cache.php
@@ -517,6 +517,42 @@ class Cache extends \Test\TestCase {
$this->assertEquals(1, count($this->cache->getFolderContents('folder')));
}
+ function bogusPathNamesProvider() {
+ return array(
+ array('/bogus.txt', 'bogus.txt'),
+ array('//bogus.txt', 'bogus.txt'),
+ array('bogus/', 'bogus'),
+ array('bogus//', 'bogus'),
+ );
+ }
+
+ /**
+ * Test bogus paths with leading or doubled slashes
+ *
+ * @dataProvider bogusPathNamesProvider
+ */
+ public function testBogusPaths($bogusPath, $fixedBogusPath) {
+ $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory');
+
+ // put root folder
+ $this->assertFalse($this->cache->get(''));
+ $parentId = $this->cache->put('', $data);
+ $this->assertGreaterThan(0, $parentId);
+
+ $this->assertGreaterThan(0, $this->cache->put($bogusPath, $data));
+
+ $newData = $this->cache->get($fixedBogusPath);
+ $this->assertNotFalse($newData);
+
+ $this->assertEquals($fixedBogusPath, $newData['path']);
+ // parent is the correct one, resolved properly (they used to not be)
+ $this->assertEquals($parentId, $newData['parent']);
+
+ $newDataFromBogus = $this->cache->get($bogusPath);
+ // same entry
+ $this->assertEquals($newData, $newDataFromBogus);
+ }
+
protected function tearDown() {
if ($this->cache) {
$this->cache->clear();
diff --git a/tests/lib/streamwrappers.php b/tests/lib/streamwrappers.php
index 9a3b6bc9266..2a8c8676c16 100644
--- a/tests/lib/streamwrappers.php
+++ b/tests/lib/streamwrappers.php
@@ -48,20 +48,13 @@ class Test_StreamWrappers extends \Test\TestCase {
//test callback
$tmpFile = OC_Helper::TmpFile('.txt');
$file = 'close://' . $tmpFile;
- \OC\Files\Stream\Close::registerCallback($tmpFile, array('Test_StreamWrappers', 'closeCallBack'));
+ $actual = false;
+ $callback = function($path) use (&$actual) { $actual = $path; };
+ \OC\Files\Stream\Close::registerCallback($tmpFile, $callback);
$fh = fopen($file, 'w');
fwrite($fh, 'asd');
- try {
- fclose($fh);
- $this->fail('Expected exception');
- } catch (Exception $e) {
- $path = $e->getMessage();
- $this->assertEquals($path, $tmpFile);
- }
- }
-
- public static function closeCallBack($path) {
- throw new Exception($path);
+ fclose($fh);
+ $this->assertSame($tmpFile, $actual);
}
public function testOC() {