From 95fbbcd60ecec5a40112cada892c833a9ec707c2 Mon Sep 17 00:00:00 2001
From: Wolfram Schneider
Date: Tue, 27 Apr 2010 14:40:43 +0200
Subject: [PATCH] Require a title (Name) for the target.
trim values before checking for id creation.
---
web/htdocs/chrome/layout.mc | 2 +-
web/htdocs/details/edit.mc | 12 +++++++-----
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/web/htdocs/chrome/layout.mc b/web/htdocs/chrome/layout.mc
index 69c0ac6..4de8b67 100644
--- a/web/htdocs/chrome/layout.mc
+++ b/web/htdocs/chrome/layout.mc
@@ -7,7 +7,7 @@ $component
use URI::Escape qw(uri_escape uri_escape_utf8);
use ZOOM;
use ZOOM::IRSpy::Web;
-use ZOOM::IRSpy::Utils qw(utf8param trimField isodate xml_encode cql_target cql_quote
+use ZOOM::IRSpy::Utils qw(utf8param trimField utf8paramTrim isodate xml_encode cql_target cql_quote
irspy_xpath_context irspy_make_identifier
irspy_record2identifier
irspy_identifier2target modify_xml_document
diff --git a/web/htdocs/details/edit.mc b/web/htdocs/details/edit.mc
index bfe3836..881b5ce 100644
--- a/web/htdocs/details/edit.mc
+++ b/web/htdocs/details/edit.mc
@@ -36,10 +36,11 @@ my $conn = new ZOOM::Connection($db, 0,
user => "admin", password => "fruitbat",
elementSetName => "zeerex");
-my $protocol = utf8param($r, "protocol");
-my $host = utf8param($r, "host");
-my $port = utf8param($r, "port");
-my $dbname = utf8param($r, "dbname");
+my $protocol = utf8paramTrim($r, "protocol");
+my $host = utf8paramTrim($r, "host");
+my $port = utf8paramTrim($r, "port");
+my $dbname = utf8paramTrim($r, "dbname");
+my $title = utf8paramTrim($r, "title");
if ((!defined $port || $port eq "") &&
(defined $protocol && $protocol ne "")) {
@@ -53,6 +54,7 @@ my $newid;
if (defined $protocol && $protocol ne "" &&
defined $host && $host ne "" &&
defined $port && $port ne "" &&
+ defined $title && $title ne "" &&
defined $dbname && $dbname ne "") {
$newid = irspy_make_identifier($protocol, $host, $port, $dbname);
}
@@ -66,7 +68,7 @@ if (!defined $id) {
} elsif (!defined $newid) {
# Tried to create new record but data is insufficient
print qq[
- Please specify protocol, host, port and database name.
\n];
+ Please specify title, protocol, host, port and database name.
\n];
undef $update;
} elsif ($host !~ /^\w+\.[\w.]*\w$/i) {
print qq[
--
1.7.10.4