Skip to content

Commit

Permalink
Merge pull request #241 from paolostivanin/rel2_4_9
Browse files Browse the repository at this point in the history
Fix QR code import
  • Loading branch information
paolostivanin authored Feb 28, 2022
2 parents 370b2e1 + f660308 commit e43f5a2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5)
project(OTPClient VERSION "2.4.8" LANGUAGES "C")
project(OTPClient VERSION "2.4.9" LANGUAGES "C")

configure_file("src/common/version.h.in" "version.h")
include_directories(${PROJECT_BINARY_DIR})
Expand Down
9 changes: 9 additions & 0 deletions data/com.github.paolostivanin.OTPClient.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ It's also possible to import/export backups from/to andOTP and import backups fr
</content_rating>

<releases>
<release version="2.4.9" date="2022-02-28">
<description>
<p>OTPClient 2.4.9 fix an import issue</p>
<ul>
<li>fix importing QR code (issue#240)</li>
<li>better error when importing a QR fails</li>
</ul>
</description>
</release>
<release version="2.4.8" date="2022-02-18">
<description>
<p>OTPClient 2.4.8 brings a couple of fixes</p>
Expand Down
3 changes: 1 addition & 2 deletions src/add-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ check_params (GSList *otps)
return g_strdup ("Label can not be empty, otp not imported");
}

if (otp->secret[0] == '\0') {
if (otp->secret == NULL || otp->secret[0] == '\0') {
return g_strdup ("Secret can not be empty, otp not imported");
}

if (g_ascii_strcasecmp (otp->type, "TOTP") == 0) {
if (otp->period < 10 || otp->period > 120) {
gchar *msg = g_strconcat("[INFO]: invalid period for '", otp->account_name, "'. Defaulting back to 30 seconds.", NULL);
Expand Down
3 changes: 2 additions & 1 deletion src/parse-uri.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ parse_parameters (const gchar *modified_uri,
const gchar *mod_uri_copy = modified_uri;
gchar **tokens = g_strsplit (mod_uri_copy, "?", -1);
gchar *escaped_issuer_and_label = g_uri_unescape_string (tokens[0], NULL);
mod_uri_copy += g_utf8_strlen (tokens[0], -1) + 1; // "issuer:label?"
mod_uri_copy += g_utf8_strlen (tokens[0], -1) + 2; // "issuer:label?"
g_strfreev (tokens);

tokens = g_strsplit (escaped_issuer_and_label, ":", -1);
Expand All @@ -88,6 +88,7 @@ parse_parameters (const gchar *modified_uri,
tokens = g_strsplit (mod_uri_copy, "&", -1);
gint i = 0;
while (tokens[i]) {

if (g_ascii_strncasecmp (tokens[i], "secret=", 7) == 0) {
tokens[i] += 7;
otp->secret = secure_strdup (tokens[i]);
Expand Down

0 comments on commit e43f5a2

Please sign in to comment.