Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

added url parsing to allow query params in urls #434

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions recovery/multiimagewritethread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <QProcessEnvironment>
#include <QSettings>
#include <QTime>
#include <QUrl>
#include <unistd.h>
#include <linux/fs.h>
#include <linux/magic.h>
Expand Down Expand Up @@ -719,26 +720,29 @@ bool MultiImageWriteThread::untar(const QString &tarball)
{
QString cmd = "sh -o pipefail -c \"";

if (isURL(tarball))
QString tarballPath = QString(tarball);
if (isURL(tarball)){
tarballPath = QUrl::fromUserInput(tarball).toString(QUrl::RemoveQuery);
cmd += "wget --no-verbose --tries=inf -O- "+tarball+" | ";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need to escape shell arguments if you are going to allow query parameters.
While ? does not have special meaning to shell, other characters that may appear such as & do.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

}

if (tarball.endsWith(".gz"))
if (tarballPath.endsWith(".gz"))
{
cmd += "gzip -dc";
}
else if (tarball.endsWith(".xz"))
else if (tarballPath.endsWith(".xz"))
{
cmd += "xz -dc";
}
else if (tarball.endsWith(".bz2"))
else if (tarballPath.endsWith(".bz2"))
{
cmd += "bzip2 -dc";
}
else if (tarball.endsWith(".lzo"))
else if (tarballPath.endsWith(".lzo"))
{
cmd += "lzop -dc";
}
else if (tarball.endsWith(".zip"))
else if (tarballPath.endsWith(".zip"))
{
/* Note: the image must be the only file inside the .zip */
cmd += "unzip -p";
Expand Down