QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
filecontent.cpp File Reference

Implements FileContent::parse() as a single streaming pass over the entry, with the field cap, the display-line cap and the OTP candidate search, plus the cached secret-field-name matcher. More...

#include "filecontent.h"
#include "totp.h"
#include <QRegularExpression>
#include <QCoreApplication>
#include <QStringTokenizer>
#include <algorithm>
#include <limits>
#include <utility>
Include dependency graph for filecontent.cpp:

Go to the source code of this file.

Functions

static auto isOtpUri (const QString &value) -> bool
 Shorthand for the public FileContent::isOtpUriValue.
static auto bareOtpUriOf (const QString &line) -> QString
 The otpauth URI a line is written as: a bare otpauth:// line, or the split otpauth: //... that 1.8 to 2.0-rc2 saved (a template field "otpauth" with the rest of the URI as its value), its blanks dropped.
static auto isLineHidden (const QString &line) -> bool
 Whether a body line must stay out of the parsed display because it carries a TOTP shared secret (FileContent::isOtpLine()). "Display the file's content as-is" bypasses this filter and shows the entry raw.
static auto isBase32Seed (const QString &value) -> bool
 Whether value is written as a TOTP seed: base32 letters and the digits 2 to 7 only (either case; white space, dashes, dots or underscores between groups and "=" padding allowed), at least 16 of them (80 bits, the shortest seed in common use), that Totp::isValid() takes.
static auto afterFirstColon (const QString &line) -> QString
 What follows a line's first colon; empty without one.
static auto holdsOtpConfig (const QString &line) -> bool
 Whether a first line is written as an OTP configuration that otpConfigOf() can read: a bare otpauth URI (split or not, see bareOtpUriOf()), a field whose value is one, or an OTP:/TOTP: field whose value is written as a base32 seed.
static auto otpConfigOf (const QString &line) -> QString
 The OTP configuration an OTP line holds: the URI for a bare otpauth:// line (bareOtpUriOf()), the value for a field.

Detailed Description

Implements FileContent::parse() as a single streaming pass over the entry, with the field cap, the display-line cap and the OTP candidate search, plus the cached secret-field-name matcher.

Definition in file filecontent.cpp.

Function Documentation

◆ afterFirstColon()

auto afterFirstColon ( const QString & line) -> QString
static

What follows a line's first colon; empty without one.

Parameters
lineOne line of the entry.
Returns
The text after the first ':', or an empty string.

Definition at line 104 of file filecontent.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bareOtpUriOf()

auto bareOtpUriOf ( const QString & line) -> QString
static

The otpauth URI a line is written as: a bare otpauth:// line, or the split otpauth: //... that 1.8 to 2.0-rc2 saved (a template field "otpauth" with the rest of the URI as its value), its blanks dropped.

Parameters
lineOne line of the entry.
Returns
The URI, trimmed, or an empty string when the line is not one.

Definition at line 37 of file filecontent.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ holdsOtpConfig()

auto holdsOtpConfig ( const QString & line) -> bool
static

Whether a first line is written as an OTP configuration that otpConfigOf() can read: a bare otpauth URI (split or not, see bareOtpUriOf()), a field whose value is one, or an OTP:/TOTP: field whose value is written as a base32 seed.

Parameters
lineThe entry's first line.
Returns
true when the line is read as the OTP configuration.

Definition at line 117 of file filecontent.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isBase32Seed()

auto isBase32Seed ( const QString & value) -> bool
static

Whether value is written as a TOTP seed: base32 letters and the digits 2 to 7 only (either case; white space, dashes, dots or underscores between groups and "=" padding allowed), at least 16 of them (80 bits, the shortest seed in common use), that Totp::isValid() takes.

Strict where Totp::parse() is lenient (it drops punctuation and reads 0, 1 and 8 as letters, which almost any password survives): this decides whether a first line is a seed or the password.

Parameters
valueThe value of an OTP:/TOTP: field.
Returns
true when it can only be read as a seed.

Definition at line 79 of file filecontent.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isLineHidden()

auto isLineHidden ( const QString & line) -> bool
static

Whether a body line must stay out of the parsed display because it carries a TOTP shared secret (FileContent::isOtpLine()). "Display the file's content as-is" bypasses this filter and shows the entry raw.

Parameters
lineOne line of the entry body.
Returns
true when the line is kept out of getRemainingDataForDisplay().

Definition at line 63 of file filecontent.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isOtpUri()

auto isOtpUri ( const QString & value) -> bool
static

Shorthand for the public FileContent::isOtpUriValue.

Parameters
valueA line or field value.
Returns
true when it is an otpauth:// URI.

Definition at line 26 of file filecontent.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ otpConfigOf()

auto otpConfigOf ( const QString & line) -> QString
static

The OTP configuration an OTP line holds: the URI for a bare otpauth:// line (bareOtpUriOf()), the value for a field.

Parameters
lineA line for which holdsOtpConfig() is true.
Returns
The configuration, trimmed.

Definition at line 139 of file filecontent.cpp.

Here is the call graph for this function:
Here is the caller graph for this function: