Author: aschnell
Date: Fri Feb 17 18:00:58 2012
New Revision: 67479
URL: http://svn.opensuse.org/viewcvs/yast?rev=67479&view=rev
Log:
- improved input validation
Modified:
trunk/s390/src/zfcp/dialogs.ycp
Modified: trunk/s390/src/zfcp/dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/s390/src/zfcp/dialogs.ycp?rev=67479&r1=67478&r2=67479&view=diff
==============================================================================
--- trunk/s390/src/zfcp/dialogs.ycp (original)
+++ trunk/s390/src/zfcp/dialogs.ycp Fri Feb 17 18:00:58 2012
@@ -75,9 +75,6 @@
*/
void ReloadZFCPDialog()
{
- ZFCPController::filter_min = (string) UI::QueryWidget(`min_chan, `Value);
- ZFCPController::filter_max = (string) UI::QueryWidget(`max_chan, `Value);
-
ZFCPController::ProbeDisks();
list<term> items = GetZFCPDiskItems();
@@ -106,7 +103,7 @@
// table header
`Right(_("ZFCP-LUN"))
);
-
+
/* Dialog content */
term content = `VBox(
`HBox(
@@ -160,8 +157,23 @@
selected = (integer) UI::QueryWidget (`id (`table), `CurrentItem);
- if (ret == `filter) {
- ReloadZFCPDialog ();
+ if (ret == `filter)
+ {
+ string filter_min = (string) UI::QueryWidget(`min_chan, `Value);
+ string filter_max = (string) UI::QueryWidget(`max_chan, `Value);
+
+ if (!ZFCPController::ValidChannel(filter_min) || !ZFCPController::ValidChannel(filter_max))
+ {
+ // error popup
+ Popup::Error(_("Invalid filter channels."));
+ ret = nil;
+ continue;
+ }
+
+ ZFCPController::filter_min = filter_min;
+ ZFCPController::filter_max = filter_max;
+
+ ReloadZFCPDialog();
ret = nil;
continue;
}
@@ -289,11 +301,13 @@
Wizard::RestoreBackButton ();
Wizard::RestoreAbortButton ();
- any ret = nil;
+ UI::ChangeWidget(`id(`channel), `ValidChars, "0123456789abcdefABCDEF.");
+ UI::ChangeWidget(`id(`wwpn), `ValidChars, "0123456789abcdefABCDEFx");
+ symbol ret = nil;
while (ret == nil)
{
- ret = UI::UserInput();
+ ret = (symbol) UI::UserInput();
if (ret == `get_wwpn){
list<string> items = ZFCPController::GetWWPNs((string)UI::QueryWidget(`channel, `Value));
@@ -316,45 +330,59 @@
}
else if (ret == `next)
{
- string wwpn = (string)UI::QueryWidget (`id (`wwpn), `Value);
- boolean ok = true;
- if (substring (wwpn, 0, 2) != "0x")
- ok = false;
- wwpn = substring (wwpn, 2);
- if (size (wwpn) != 16)
- ok = false;
- if (size (filterchars (wwpn, "1234567890abcdef")) != 16)
- ok = false;
- if (! ok)
+ string channel = (string) UI::QueryWidget(`id(`channel), `Value);
+ string wwpn = (string) UI::QueryWidget(`id(`wwpn), `Value);
+ string fcp_lun = (string) UI::QueryWidget(`id(`fcp_lun), `Value);
+
+ if (!ZFCPController::ValidChannel(channel))
{
- // error report
- Report::Error (_("The entered WWPN is invalid."));
- UI::SetFocus (`wwpn);
+ // error popup
+ Popup::Error(_("Not a valid channel."));
+ UI::SetFocus(`channel);
ret = nil;
+ continue;
+ }
+
+ if (!ZFCPController::ValidWWPN(wwpn))
+ {
+ // error popup
+ Report::Error(_("The entered WWPN is invalid."));
+ UI::SetFocus(`wwpn);
+ ret = nil;
+ continue;
+ }
+
+ if (!ZFCPController::ValidFCPLUN(fcp_lun))
+ {
+ // error popup
+ Report::Error(_("The entered FCP-LUN is invalid."));
+ UI::SetFocus(`fcp_lun);
+ ret = nil;
+ continue;
}
}
}
if (ret == `next)
{
- string channel = (string)UI::QueryWidget (`id (`channel), `Value);
- string wwpn = (string)UI::QueryWidget (`id (`wwpn), `Value);
- string lun = (string)UI::QueryWidget (`id (`fcp_lun), `Value);
+ string channel = (string) UI::QueryWidget(`id(`channel), `Value);
+ string wwpn = (string) UI::QueryWidget(`id(`wwpn), `Value);
+ string lun = (string) UI::QueryWidget(`id(`fcp_lun), `Value);
ZFCPController::previous_settings["wwpm"] = wwpn;
ZFCPController::previous_settings["fcp_lun"] = lun;
ZFCPController::previous_settings["channel"] = channel;
- if (Mode::config ())
+
+ if (Mode::config())
{
map