Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-10-11 20:34:23 +0300
committerGitHub <noreply@github.com>2016-10-11 20:34:23 +0300
commitdc0051555f207b76deb675c75b3fe46f82ec55d6 (patch)
tree43d81210220d8c00b08bea76cc5263422fd37c53 /apps
parent713d04ac3b2ef294a37af7dd1d355ff0f14ca427 (diff)
parent522e71450c17fb19daeed1d0bcc6b4f656033ea4 (diff)
Merge pull request #26340 from owncloud/stable9.1-36d6f3ba8b7b7db8f4d8b2a70504fd184a30cc50
[stable9.1] Escape special characters
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/Connector/Sabre/CustomPropertiesBackend.php2
-rw-r--r--apps/user_ldap/lib/Access.php2
-rw-r--r--apps/user_ldap/lib/Mapping/AbstractMapping.php6
-rw-r--r--apps/user_ldap/tests/Mapping/AbstractMappingTest.php2
4 files changed, 7 insertions, 5 deletions
diff --git a/apps/dav/lib/Connector/Sabre/CustomPropertiesBackend.php b/apps/dav/lib/Connector/Sabre/CustomPropertiesBackend.php
index d0d348e170e..b319350c7f0 100644
--- a/apps/dav/lib/Connector/Sabre/CustomPropertiesBackend.php
+++ b/apps/dav/lib/Connector/Sabre/CustomPropertiesBackend.php
@@ -327,7 +327,7 @@ class CustomPropertiesBackend implements BackendInterface {
$result = $this->connection->executeQuery(
$sql,
- array($this->user, rtrim($path, '/') . '/%', $requestedProperties),
+ array($this->user, $this->connection->escapeLikeParameter(rtrim($path, '/')) . '/%', $requestedProperties),
array(null, null, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY)
);
diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php
index 4d0753696ff..cdf12331477 100644
--- a/apps/user_ldap/lib/Access.php
+++ b/apps/user_ldap/lib/Access.php
@@ -623,7 +623,7 @@ class Access extends LDAPUtility implements IUserTools {
* "Developers"
*/
private function _createAltInternalOwnCloudNameForGroups($name) {
- $usedNames = $this->groupMapper->getNamesBySearch($name.'_%');
+ $usedNames = $this->groupMapper->getNamesBySearch($name, "", '_%');
if(!($usedNames) || count($usedNames) === 0) {
$lastNo = 1; //will become name_2
} else {
diff --git a/apps/user_ldap/lib/Mapping/AbstractMapping.php b/apps/user_ldap/lib/Mapping/AbstractMapping.php
index 54fe7db366f..67fbd9fe851 100644
--- a/apps/user_ldap/lib/Mapping/AbstractMapping.php
+++ b/apps/user_ldap/lib/Mapping/AbstractMapping.php
@@ -138,16 +138,18 @@ abstract class AbstractMapping {
/**
* Searches mapped names by the giving string in the name column
* @param string $search
+ * @param string $prefixMatch
+ * @param string $postfixMatch
* @return string[]
*/
- public function getNamesBySearch($search) {
+ public function getNamesBySearch($search, $prefixMatch = "", $postfixMatch = "") {
$query = $this->dbc->prepare('
SELECT `owncloud_name`
FROM `'. $this->getTableName() .'`
WHERE `owncloud_name` LIKE ?
');
- $res = $query->execute(array($search));
+ $res = $query->execute(array($prefixMatch.$this->dbc->escapeLikeParameter($search).$postfixMatch));
$names = array();
if($res !== false) {
while($row = $query->fetch()) {
diff --git a/apps/user_ldap/tests/Mapping/AbstractMappingTest.php b/apps/user_ldap/tests/Mapping/AbstractMappingTest.php
index ddd99d31709..a2e9f850913 100644
--- a/apps/user_ldap/tests/Mapping/AbstractMappingTest.php
+++ b/apps/user_ldap/tests/Mapping/AbstractMappingTest.php
@@ -164,7 +164,7 @@ abstract class AbstractMappingTest extends \Test\TestCase {
public function testSearch() {
list($mapper,) = $this->initTest();
- $names = $mapper->getNamesBySearch('%oo%');
+ $names = $mapper->getNamesBySearch('oo', '%', '%');
$this->assertTrue(is_array($names));
$this->assertSame(2, count($names));
$this->assertTrue(in_array('Foobar', $names));