Clean up some coding standard violations in MIME type code
Trivia, noticed while assessing security risk. Stray braces where they aren't needed. Long lines: reflowed comments and split a declaration. Task-number: QTBUG-135191 Change-Id: I3e19673fc35bd7ee12a6e62849d12810e8997cdf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
578852f4ca
commit
4b3a1bf272
@ -394,9 +394,9 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
|
|||||||
if (candidateByData.isValid() && magicAccuracy > 0) {
|
if (candidateByData.isValid() && magicAccuracy > 0) {
|
||||||
const QString sniffedMime = candidateByData.name();
|
const QString sniffedMime = candidateByData.name();
|
||||||
// If the sniffedMime matches a highest-weight glob match, use it
|
// If the sniffedMime matches a highest-weight glob match, use it
|
||||||
if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
|
if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime))
|
||||||
return candidateByData;
|
return candidateByData;
|
||||||
}
|
|
||||||
for (const QString &m : std::as_const(candidatesByName.m_allMatchingMimeTypes)) {
|
for (const QString &m : std::as_const(candidatesByName.m_allMatchingMimeTypes)) {
|
||||||
if (inherits(m, sniffedMime)) {
|
if (inherits(m, sniffedMime)) {
|
||||||
// We have magic + pattern pointing to this, so it's a pretty good match
|
// We have magic + pattern pointing to this, so it's a pretty good match
|
||||||
|
@ -191,9 +191,9 @@ void QMimeAllGlobPatterns::addGlob(const QMimeGlobPattern &glob)
|
|||||||
const QString &pattern = glob.pattern();
|
const QString &pattern = glob.pattern();
|
||||||
Q_ASSERT(!pattern.isEmpty());
|
Q_ASSERT(!pattern.isEmpty());
|
||||||
|
|
||||||
// Store each patterns into either m_fastPatternDict (*.txt, *.html etc. with default weight 50)
|
// Store each patterns into either m_fastPatternDict (*.txt, *.html
|
||||||
// or for the rest, like core.*, *.tar.bz2, *~, into highWeightPatternOffset (>50)
|
// etc. with default weight 50) or for the rest, like core.*, *.tar.bz2, *~,
|
||||||
// or lowWeightPatternOffset (<=50)
|
// into highWeightPatternOffset (>50) or lowWeightPatternOffset (<=50).
|
||||||
|
|
||||||
if (glob.weight() == 50 && isFastPattern(pattern) && !glob.isCaseSensitive()) {
|
if (glob.weight() == 50 && isFastPattern(pattern) && !glob.isCaseSensitive()) {
|
||||||
// The bulk of the patterns is *.foo with weight 50 --> those go into the fast patterns hash.
|
// The bulk of the patterns is *.foo with weight 50 --> those go into the fast patterns hash.
|
||||||
@ -249,12 +249,11 @@ void QMimeAllGlobPatterns::matchingGlobs(const QString &fileName, QMimeGlobMatch
|
|||||||
const QStringList matchingMimeTypes = m_fastPatterns.value(simpleExtension);
|
const QStringList matchingMimeTypes = m_fastPatterns.value(simpleExtension);
|
||||||
const QString simplePattern = "*."_L1 + simpleExtension;
|
const QString simplePattern = "*."_L1 + simpleExtension;
|
||||||
for (const QString &mime : matchingMimeTypes) {
|
for (const QString &mime : matchingMimeTypes) {
|
||||||
if (filterFunc(mime)) {
|
if (filterFunc(mime))
|
||||||
result.addMatch(mime, 50, simplePattern, simpleExtension.size());
|
result.addMatch(mime, 50, simplePattern, simpleExtension.size());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Can't return yet; *.tar.bz2 has to win over *.bz2, so we need the low-weight mimetypes anyway,
|
// Can't return yet; *.tar.bz2 has to win over *.bz2, so we need the
|
||||||
// at least those with weight 50.
|
// low-weight mimetypes anyway, at least those with weight 50.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, try the low weight matches (<=50)
|
// Finally, try the low weight matches (<=50)
|
||||||
|
@ -45,7 +45,9 @@ public:
|
|||||||
static const unsigned DefaultWeight = 50;
|
static const unsigned DefaultWeight = 50;
|
||||||
static const unsigned MinWeight = 1;
|
static const unsigned MinWeight = 1;
|
||||||
|
|
||||||
explicit QMimeGlobPattern(const QString &thePattern, const QString &theMimeType, unsigned theWeight = DefaultWeight, Qt::CaseSensitivity s = Qt::CaseInsensitive) :
|
explicit QMimeGlobPattern(const QString &thePattern, const QString &theMimeType,
|
||||||
|
unsigned theWeight = DefaultWeight,
|
||||||
|
Qt::CaseSensitivity s = Qt::CaseInsensitive) :
|
||||||
m_pattern(s == Qt::CaseInsensitive ? thePattern.toLower() : thePattern),
|
m_pattern(s == Qt::CaseInsensitive ? thePattern.toLower() : thePattern),
|
||||||
m_mimeType(theMimeType),
|
m_mimeType(theMimeType),
|
||||||
m_weight(theWeight),
|
m_weight(theWeight),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user