Changeset 8408511


Ignore:
Timestamp:
Nov 22, 2013 7:41:39 AM (5 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0, releng/10.0.1
Children:
17e625c
Parents:
922329d
Message:

Make sure that the pc-bootmanager only allows BE names comiprised of letters/numbers (no symbols).

Location:
src-qt4/pc-bootconfig
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-bootconfig/mainUI.cpp

    rc3b1e67 r8408511  
    6565  } 
    6666  return ok; 
     67} 
     68 
     69bool mainUI::validateInput(QString name){ 
     70  //Check for invalid name characters (only letters/numbers) 
     71  bool ok = true; 
     72  for(int i=0; i<name.length(); i++){ 
     73    if( !name.at(i).isLetter() && !name.at(i).isDigit() ){ ok = false; break; } 
     74  } 
     75  if(!ok){ 
     76    QMessageBox::warning(this,tr("Invalid Name"), tr("Boot Environment names may only be comprised of letters and numbers") ); 
     77  } 
     78  return ok;   
    6779} 
    6880 
     
    311323  //Get the new name from the user 
    312324  bool ok; 
    313   QString newname = QInputDialog::getText( this, tr("New BE name"), tr("Choose a name for the new boot environment"), QLineEdit::Normal, "", &ok);  
     325  QString newname = QInputDialog::getText( this, tr("New BE name"), tr("Choose a name for the new boot environment"), QLineEdit::Normal, "", &ok,0, Qt::ImhLowercaseOnly | Qt::ImhUppercaseOnly | Qt::ImhDigitsOnly);  
    314326  if(ok && !newname.isEmpty()){ 
     327    if( !validateInput(newname) ){ 
     328      on_tool_BEadd_clicked(); //try again 
     329      return; 
     330    } 
    315331    if( checkName(newname) ){ 
    316332      if(updateGRUB && !G_showMenu){  
     
    350366    //Get the new name from the user 
    351367    bool ok; 
    352     QString newname = QInputDialog::getText( this, tr("New BE name"), tr("Choose a name for the new boot environment"), QLineEdit::Normal, name, &ok);  
     368    QString newname = QInputDialog::getText( this, tr("New BE name"), tr("Choose a name for the new boot environment"), QLineEdit::Normal, name, &ok,0, Qt::ImhDigitsOnly | Qt::ImhUppercaseOnly | Qt::ImhLowercaseOnly);  
    353369    if(ok && !newname.isEmpty()){ 
     370      if( !validateInput(newname) ){ 
     371        on_tool_BEcp_clicked(); //try again 
     372        return; 
     373      } 
    354374      if( checkName(newname) ){ 
    355375        if(updateGRUB && !G_showMenu){  
     
    375395    //Get the new name from the user 
    376396    bool ok; 
    377     QString newname = QInputDialog::getText( this, tr("New BE name"), tr("Choose a new name for this boot environment"), QLineEdit::Normal, name, &ok);  
     397    QString newname = QInputDialog::getText( this, tr("New BE name"), tr("Choose a new name for this boot environment"), QLineEdit::Normal, name, &ok,0, Qt::ImhLowercaseOnly | Qt::ImhUppercaseOnly | Qt::ImhDigitsOnly );  
    378398    if(ok && !newname.isEmpty()){ 
     399      if( !validateInput(newname) ){ 
     400        on_tool_BEmv_clicked(); //try again 
     401        return; 
     402      } 
    379403      if( checkName(newname) ){ 
    380404        beadmRename(name,newname); 
  • src-qt4/pc-bootconfig/mainUI.h

    r1361cd4 r8408511  
    3939        int getSelectedBE(); //get the currently selected Boot Environment index 
    4040        bool checkName(QString); //make sure the selected name is valid 
     41        bool validateInput(QString); //Make sure the input text is number/letter 
    4142        void runLongCMD(QString cmd , QString info = "");  
    4243 
Note: See TracChangeset for help on using the changeset viewer.