Merge branch 'master' of ssh://git.indexdata.com/home/git/pub/irspy
authorWolfram Schneider <wosch@indexdata.dk>
Tue, 27 Apr 2010 15:44:59 +0000 (15:44 +0000)
committerWolfram Schneider <wosch@indexdata.dk>
Tue, 27 Apr 2010 15:44:59 +0000 (15:44 +0000)
lib/ZOOM/IRSpy/Utils.pm
web/htdocs/chrome/layout.mc
web/htdocs/details/edit.mc

index 1dc25e1..233222e 100644 (file)
@@ -10,6 +10,7 @@ use Scalar::Util;
 use Exporter 'import';
 our @EXPORT_OK = qw(utf8param
                    trimField
+                   utf8paramTrim
                    isodate
                    xml_encode 
                    cql_quote
@@ -83,7 +84,6 @@ sub utf8param {
     return $cooked;
 }
 
-
 # Utility functions follow, exported for use of web UI
 sub utf8param_apache1 {
     my($r, $key, $value) = @_;
@@ -115,6 +115,17 @@ sub trimField {
     return $field;
 }
 
+# utf8param() with trim
+sub utf8paramTrim {
+    my $result = utf8param(@_);
+
+    if (defined $result) {
+       $result = trimField($result);   
+    }
+
+    return $result;
+}
+
 # I can't -- just can't, can't, can't -- believe that this function
 # isn't provided by one of the core XML modules.  But the evidence all
 # says that it's not: among other things, XML::Generator and
index 69c0ac6..4de8b67 100644 (file)
@@ -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
index bfe3836..881b5ce 100644 (file)
@@ -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[<p class="error">
-               Please specify protocol, host, port and database name.</p>\n];
+               Please specify title, protocol, host, port and database name.</p>\n];
        undef $update;
     } elsif ($host !~ /^\w+\.[\w.]*\w$/i) {
        print qq[<p class="error">