Skip to content

Commit

Permalink
Validate user input [BUG-131]
Browse files Browse the repository at this point in the history
  • Loading branch information
brezerk committed Aug 31, 2018
1 parent de540df commit 51d0cb9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/q4wine-gui/appsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,15 @@ void AppSettings::cmdOk_Click(){
#endif

QString desktopSize=cboxDesktopSize->currentText();
if (desktopSize==tr("No virtual desktop"))
if (desktopSize==tr("No virtual desktop")){
desktopSize="";
} else {
QRegExp res_match("^\\d{3,}x\\d{3,}$");
if (!res_match.exactMatch(desktopSize)){
QMessageBox::warning(this, tr("Error"), tr("Invalid virtual desktop size."));
return;
}
}

settings.setValue("defaultDesktopSize", desktopSize);

Expand Down
9 changes: 8 additions & 1 deletion src/q4wine-gui/iconsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,15 @@ void IconSettings::cmdOk_Click(){

QString desktopSize=cboxDesktopSize->currentText();

if (desktopSize==tr("No virtual desktop"))
if (desktopSize==tr("No virtual desktop")) {
desktopSize="";
} else {
QRegExp res_match("^\\d{3,}x\\d{3,}$");
if (!res_match.exactMatch(desktopSize)){
QMessageBox::warning(this, tr("Error"), tr("Invalid virtual desktop size."));
return;
}
}

if (this->icon_name.isEmpty()){
db_icon.addIcon(txtCmdArgs->text(), txtProgramPath->text(), iconPath, txtDesc->text(), this->prefix_name, this->dir_name, txtName->text(), override, txtWinedebug->text(), useconsole, txtDisplay->text(), txtWorkDir->text(), desktopSize, spinNice->value(), txtEnvLang->text(), txtPreRun->text(), txtPostRun->text());
Expand Down
5 changes: 5 additions & 0 deletions src/q4wine-gui/run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ void Run::cmdOk_Click(){
if (cboxDesktopSize->currentText()==tr("No virtual desktop")){
execObj.desktop="";
} else {
QRegExp res_match("^\\d{3,}x\\d{3,}$");
if (!res_match.exactMatch(cboxDesktopSize->currentText())){
QMessageBox::warning(this, tr("Error"), tr("Invalid virtual desktop size."));
return;
}
execObj.desktop=cboxDesktopSize->currentText();
}

Expand Down

0 comments on commit 51d0cb9

Please sign in to comment.