Skip to content

Commit

Permalink
* [FIX] Wrong behavior when importing CSV. Thanks to @hoboristi for t…
Browse files Browse the repository at this point in the history
…he feedback. Closes #1211

* [FIX] Wrong behavior when displaying passwords with scpecial characters. Thanks to @opeshm for the feedback. Closes #1207

Signed-off-by: Rubén D <[email protected]>
  • Loading branch information
nuxsmin committed Jan 26, 2019
1 parent a65d261 commit 26261c0
Show file tree
Hide file tree
Showing 8 changed files with 201 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function getPasswordView(AccountPassData $accountData, bool $useImage)
$this->view->assign('pass', $imageUtil->convertText($pass));
} else {
$this->view->assign('login', $accountData->getLogin());
$this->view->assign('pass', htmlentities($pass));
$this->view->assign('pass', htmlentities($pass, ENT_COMPAT | ENT_HTML5));
}

return [
Expand Down
2 changes: 1 addition & 1 deletion lib/SP/Services/Import/ImportTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ protected function getWorkingItem($type, $value)
protected function addWorkingItem($type, $value, $id)
{
if (isset($this->items[$type][$value])) {
return false;
return $this->items[$type][$value];
}

$this->items[$type][$value] = $id;
Expand Down
4 changes: 2 additions & 2 deletions tests/SP/Services/Import/CsvImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function testDoImport()
$import = new CsvImport(self::$dic, FileImport::fromFilesystem($file), $params);
$import->doImport();

$this->assertEquals(3, $import->getCounter());
$this->assertEquals(4, $import->getCounter());

$this->checkImportedData();
}
Expand Down Expand Up @@ -157,7 +157,7 @@ private function checkImportedData()

$this->assertEquals('csv_pass3', Crypt::decrypt($pass->getPass(), $pass->getKey(), '12345678900'));

$this->assertEquals(5, $this->conn->getRowCount('Account'));
$this->assertEquals(6, $this->conn->getRowCount('Account'));
}

/**
Expand Down
9 changes: 5 additions & 4 deletions tests/res/config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
<accountFullGroupAccess>0</accountFullGroupAccess>
<accountLink>1</accountLink>
<accountPassToImage>0</accountPassToImage>
<appVersion></appVersion>
<authBasicAutoLoginEnabled>1</authBasicAutoLoginEnabled>
<authBasicDomain></authBasicDomain>
<authBasicEnabled>1</authBasicEnabled>
<backup_hash>cfa7b7e1f0ddcf064e54448f900e9958fca308c1</backup_hash>
<backup_hash>4d7fc39824dba286bd33ae0e68353b75e1181f7f</backup_hash>
<checkUpdates>0</checkUpdates>
<checknotices>0</checknotices>
<configDate>1544965203</configDate>
<configHash>d13dd5f27bf6112c0665aa586c9581efee6ddbc9</configHash>
<configDate>1548499643</configDate>
<configHash>24275a94c07791c9af1ff211ff6e16c638a900bd</configHash>
<configSaver>sysPass</configSaver>
<configVersion></configVersion>
<databaseVersion></databaseVersion>
Expand All @@ -32,7 +33,7 @@
<dokuwikiUrlBase></dokuwikiUrlBase>
<dokuwikiUser></dokuwikiUser>
<encryptSession>0</encryptSession>
<export_hash>f25c6da263b2b6735b3e10a8ab1dba4d3ba6200a</export_hash>
<export_hash>c82d9a7be95b0c2acb10082b7fdc97c34ed726fc</export_hash>
<filesAllowedExts>
<item type="filesAllowedExts">PDF</item>
<item type="filesAllowedExts">JPG</item>
Expand Down
3 changes: 2 additions & 1 deletion tests/res/import/data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ bla
bla
car
"
"Test CSV 3";"Apple";"SSH";"http://apple.com";"csv_login2";"csv_pass3";"CSV Notes 3"
"Test CSV 3";"Apple";"SSH";"http://apple.com";"csv_login2";"csv_pass3";"CSV Notes 3"
"Test CSV 1";"CSV Client 1";"CSV Category 1";"http://test.me";"csv_login1";"csv_pass1";"CSV Notes"
127 changes: 127 additions & 0 deletions tests/res/scripts/db.sql

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions tests/res/scripts/dump_to_xml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

DB_HOST=$(docker inspect syspass-db-test --format {{.NetworkSettings.Networks.bridge.IPAddress}})

if [ -z "${DB_HOST}" ]; then
echo "Unknown host"
exit 1
fi

DB_TABLE=$1
DUMP_PATH=$2

if [ -z ${DB_TABLE} ]; then
echo "Table not set"
exit 1
fi

if [ -z ${DUMP_PATH} ]; then
echo "Dump path not set"
exit 1
fi

mysqldump --hex-blob -t -u root --password=syspass-test --host=${DB_HOST} --xml syspass-test `echo "${DB_TABLE^}"` >> ${DUMP_PATH}/syspass_${DB_TABLE}.xml
40 changes: 40 additions & 0 deletions tests/res/scripts/reset_db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

DB_HOST=$(docker inspect syspass-db-test --format {{.NetworkSettings.Networks.bridge.IPAddress}})

if [[ -z "${DB_HOST}" ]]; then
echo "Unknown host"
exit 1
fi

SQL_FILE=$1
DB_NAME=$2
PROJECT_DIR=$3

if [[ ! -e "${SQL_FILE}" ]]; then
echo "SQL file does not exist: ${SQL_FILE}"
exit 1
fi

echo "Database host: ${DB_HOST}"
echo "Database name: ${DB_NAME}"

case ${DB_NAME} in
"syspass")
mysql -h ${DB_HOST} -u root -psyspass ${DB_NAME} < ${PROJECT_DIR}/schemas/dbstructure.sql
mysql -h ${DB_HOST} -u root -psyspass ${DB_NAME} < ${SQL_FILE}
;;
"syspass-test")
mysql -h ${DB_HOST} -u root -psyspass -e 'DROP DATABASE IF EXISTS `'"${DB_NAME}"'`;'
mysql -h ${DB_HOST} -u root -psyspass -e 'CREATE DATABASE `'"${DB_NAME}"'` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;'
mysql -h ${DB_HOST} -u root -psyspass ${DB_NAME} < ${SQL_FILE}
;;
*)
echo "Database name not set"
exit 1
;;
esac

if [[ $? -eq 0 ]]; then
echo "Database data imported"
fi

0 comments on commit 26261c0

Please sign in to comment.