summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
authorAaron Wood <aaronjwood@gmail.com>2016-07-20 08:20:45 -0400
committerLukas Reschke <lukas@statuscode.ch>2016-07-20 14:46:47 +0200
commit7c0de08cc44e0b04f23d6f3fa2d6030991935c54 (patch)
tree8a680779c0e7a661a8f1f3d2f998e8cbe543c3da /apps/user_ldap/lib
parentb37e1ed17f54916e3321427d92afa3f74ebea1b3 (diff)
downloadnextcloud-server-7c0de08cc44e0b04f23d6f3fa2d6030991935c54.tar.gz
nextcloud-server-7c0de08cc44e0b04f23d6f3fa2d6030991935c54.zip
Escape special characters (#25429)
* Escape LIKE parameter * Escape LIKE parameter * Escape LIKE parameter * Escape LIKE parameter * Escape LIKE parameter * Use correct method in the AbstractMapping class * Change the getNamesBySearch method so that input can be properly escaped while still supporting matches * Don't escape hardcoded wildcard
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/Access.php2
-rw-r--r--apps/user_ldap/lib/Mapping/AbstractMapping.php6
2 files changed, 5 insertions, 3 deletions
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()) {