summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Mielke <thomas.mielke@c3s.cc>2023-07-09 14:25:06 +0200
committerThomas Mielke <thomas.mielke@c3s.cc>2023-07-09 14:25:06 +0200
commita45da0a326fa7b3541d82bf7f4b93ec3751648e9 (patch)
tree5eed9bc51a8e92a49542fd057976c050bef97189
parent60a7160ea7cf050aed20d209a5de85e8575f67a7 (diff)
solved two Windows-specific issues
1. harmoized path separators in Pass::getGpgIdPath() as the pass store path couldn't match with the gpgIdDir because of trailing backslashes so two absolute paths were concatenated, leading to checkmarks not set properly in usersdialog.cpp, for example. 2. added an optional \r in regex of ImitatePass::verifyGpgIdFile() to comply with Windows \r\n linebreaks as QRegularExpression::MultilineOption won't honor \r as part of a line separator.
-rw-r--r--src/imitatepass.cpp2
-rw-r--r--src/pass.cpp14
2 files changed, 9 insertions, 7 deletions
diff --git a/src/imitatepass.cpp b/src/imitatepass.cpp
index c6492813..307670de 100644
--- a/src/imitatepass.cpp
+++ b/src/imitatepass.cpp
@@ -286,7 +286,7 @@ bool ImitatePass::verifyGpgIdFile(const QString &file) {
QStringList{"--verify", "--status-fd=1", pgpg(file) + ".sig", pgpg(file)};
exec.executeBlocking(QtPassSettings::getGpgExecutable(), args, &out);
QRegularExpression re(
- "^\\[GNUPG:\\] VALIDSIG ([A-F0-9]{40}) .* ([A-F0-9]{40})$",
+ "^\\[GNUPG:\\] VALIDSIG ([A-F0-9]{40}) .* ([A-F0-9]{40})\\r?$",
QRegularExpression::MultilineOption);
QRegularExpressionMatch m = re.match(out);
if (!m.hasMatch())
diff --git a/src/pass.cpp b/src/pass.cpp
index 4547ba9c..fdc8fdc9 100644
--- a/src/pass.cpp
+++ b/src/pass.cpp
@@ -284,13 +284,15 @@ void Pass::updateEnv() {
* @return path to the gpgid file.
*/
QString Pass::getGpgIdPath(QString for_file) {
- QDir gpgIdDir(QFileInfo(for_file.startsWith(QtPassSettings::getPassStore())
- ? for_file
- : QtPassSettings::getPassStore() + for_file)
- .absoluteDir());
+ QString passStore =
+ QDir::fromNativeSeparators(QtPassSettings::getPassStore());
+ QDir gpgIdDir(
+ QFileInfo(QDir::fromNativeSeparators(for_file).startsWith(passStore)
+ ? for_file
+ : QtPassSettings::getPassStore() + for_file)
+ .absoluteDir());
bool found = false;
- while (gpgIdDir.exists() &&
- gpgIdDir.absolutePath().startsWith(QtPassSettings::getPassStore())) {
+ while (gpgIdDir.exists() && gpgIdDir.absolutePath().startsWith(passStore)) {
if (QFile(gpgIdDir.absoluteFilePath(".gpg-id")).exists()) {
found = true;
break;