Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Ark
Commits
db07d363
Commit
db07d363
authored
Nov 03, 2022
by
David Redondo
🏎
Browse files
Fix inifinite loop in findCommonPrefixForUrls
Some mimetypes apply to files without extensions and only the filename.
parent
f891f6bd
Pipeline
#260845
passed with stage
in 3 minutes and 39 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
autotests/kerfuffle/addtoarchivetest.cpp
View file @
db07d363
...
...
@@ -98,6 +98,13 @@ void AddToArchiveTest::testCompressHere_data()
<<
QStringLiteral
(
"test-3.4.0.tar.gz"
)
<<
2ULL
;
QTest
::
newRow
(
"compress here (as TAR) - files with mimetypes but no extension (no infinite loop)"
)
<<
QStringLiteral
(
"tar.gz"
)
<<
Archive
::
Unencrypted
<<
QStringList
{
QFINDTESTDATA
(
"data/Makefile"
),
QFINDTESTDATA
(
"data/README"
)}
<<
QStringLiteral
(
"Archive.tar.gz"
)
<<
2ULL
;
if
(
!
PluginManager
().
preferredWritePluginsFor
(
QMimeDatabase
().
mimeTypeForName
(
QStringLiteral
(
"application/zip"
))).
isEmpty
())
{
QTest
::
newRow
(
"compress here (as ZIP) - dir with files"
)
<<
QStringLiteral
(
"zip"
)
...
...
autotests/kerfuffle/data/Makefile
0 → 100644
View file @
db07d363
kerfuffle/addtoarchive.cpp
View file @
db07d363
...
...
@@ -211,7 +211,11 @@ QString findCommonPrefixForUrls(const QList<QUrl> &list)
// Strip filename of its extension, but only if present (see #362690).
// Use loops to handle cases like `*.tar.gz`.
while
(
!
QMimeDatabase
().
mimeTypeForFile
(
fileName
,
QMimeDatabase
::
MatchExtension
).
isDefault
())
{
fileName
=
QFileInfo
(
fileName
).
completeBaseName
();
const
QString
strippedName
=
QFileInfo
(
fileName
).
completeBaseName
();
if
(
strippedName
==
fileName
)
{
break
;
}
fileName
=
strippedName
;
}
if
(
prefix
.
length
()
>
fileName
.
length
())
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment