[gnome-boxes] spice-display: Be more strict when validating URI
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] spice-display: Be more strict when validating URI
- Date: Tue, 28 Jun 2016 14:41:37 +0000 (UTC)
commit e04de7009da72942dd74ef88659271c87e64fe74
Author: Pavel Grunt <pgrunt redhat com>
Date: Tue Apr 26 15:58:47 2016 +0200
spice-display: Be more strict when validating URI
Throw an error if the URI scheme is invalid.
https://bugzilla.gnome.org/show_bug.cgi?id=743303
src/spice-display.vala | 16 +++++++++-------
src/wizard.vala | 2 +-
2 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/src/spice-display.vala b/src/spice-display.vala
index 9fda879..66c2691 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -549,14 +549,16 @@ static void spice_validate_uri (string uri_as_text,
tls_port = int.parse (query.get ("tls-port"));
}
- if (uri.scheme == "spice+unix") {
- if (port > 0 ||
- (uri.query_raw ?? uri.query) != null)
- throw new Boxes.Error.INVALID (_("Invalid Spice UNIX URL"));
- } else if (uri.scheme.has_prefix("spice+")) {
- throw new Boxes.Error.INVALID (_("Invalid URI"));
- } else {
+ switch (uri.scheme) {
+ case "spice":
if (port <= 0 && tls_port <= 0)
throw new Boxes.Error.INVALID (_("Missing port in Spice URL"));
+ break;
+ case "spice+unix":
+ if (port > 0 || uri.query_raw != null || uri.query != null)
+ throw new Boxes.Error.INVALID (_("Invalid URL"));
+ break;
+ default:
+ throw new Boxes.Error.INVALID (_("Invalid URL"));
}
}
diff --git a/src/wizard.vala b/src/wizard.vala
index f07b6d9..3fabf79 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -321,7 +321,7 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
source = new CollectionSource (uri.server ?? uri_as_text, uri.scheme, uri_as_text);
- if (uri.scheme == "spice" || uri.scheme.has_prefix("spice+")) {
+ if (uri.scheme.has_prefix ("spice")) {
spice_validate_uri (uri_as_text);
source.source_type = "spice";
} else if (uri.scheme == "vnc") {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]