[MOBY-guts] biomoby commit

Eddie Kawas kawas at dev.open-bio.org
Fri Aug 22 19:12:20 UTC 2008


kawas
Fri Aug 22 15:12:20 EDT 2008
Update of /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY
In directory dev.open-bio.org:/tmp/cvs-serv30752/Perl/MOBY-Server/lib/MOBY

Modified Files:
	Central.pm 
Log Message:
added utf8 encoding checks on all (most) data passed to the registry. if data passed is not utf8 encoded then an error message stating that the encoding is invalid is returned
moby-live/Perl/MOBY-Server/lib/MOBY Central.pm,1.5,1.6
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/Central.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/Central.pm	2008/05/14 14:06:23	1.5
+++ /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/Central.pm	2008/08/22 19:12:20	1.6
@@ -27,14 +27,8 @@
 use LWP;
 use MOBY::CommonSubs;
 
-#use MOBY::RDF::ServiceInstanceRDF;
-#use RDF::Core;
-#use RDF::Core::Model;
-#use RDF::Core::Literal;
-#use RDF::Core::Statement;
-#use RDF::Core::Model::Serializer;
-#use RDF::Core::Storage::Memory;
-#use RDF::Core::Constants qw(:xml :rdf :rdfs);
+use Encode;
+
 use MOBY::MobyXMLConstants;
 my $debug = 0;
 my $listener = 1;
@@ -302,6 +296,14 @@
 			""
 		);
 	}
+	#print STDERR "$term, $desc, $auth, $email\n";
+	#check encoding
+	unless ( decode_utf8($term) eq $term && decode_utf8($desc) eq $desc && decode_utf8($auth) eq $auth && decode_utf8($email) eq $email )
+	{
+		return &_error("Invalid character encoding; one or all of objectType, Description, authURI or contactEmail were not UTF-8 encoded.",
+			""
+		);
+	}
 	return &_error( "Malformed authURI - must not have an http:// prefix", "" )
 	  if $auth =~ '[/:]';
 	return &_error( "Malformed authURI - must take the form NNN.NNN.NNN", "" )
@@ -660,6 +662,15 @@
 			""
 		);
 	}
+	#check character encoding
+	unless ( decode_utf8( $term ) eq $term && decode_utf8( $desc ) eq $desc && decode_utf8( $auth ) eq $auth && decode_utf8( $email ) eq $email )
+	{
+		return &_error(
+"Invalid character encoding\n One of serviceType, Description, authURI or contactEmail were not UTF-8 encoded.",
+			""
+		);
+	}
+
 	return &_error( "Malformed authURI - must not have an http:// prefix", "" )
 	  if $auth =~ '[/:]';
 	return &_error( "Malformed authURI - must take the form NNN.NNN.NNN", "" )
@@ -910,6 +921,7 @@
 "\n\npayload\n**********************\n$payload\n***********************\n\n"
 	  );
 	my ( $term, $auth, $desc, $email ) = &_registerNamespacePayload($payload);
+
 	$debug && &_LOG("\n\nterm $term\ndesc $desc\nemail $email\nauth $auth");
 	unless ( defined $term && defined $desc && defined $auth && defined $email )
 	{
@@ -918,6 +930,16 @@
 			""
 		);
 	}
+
+	# check encoding
+	unless ( decode_utf8( $term ) eq $term && decode_utf8( $desc ) eq $desc && decode_utf8( $auth ) eq $auth && decode_utf8( $email ) eq $email )
+	{
+		return &_error(
+"Invalid character encoding; one or all of namespaceType, Description, authURI or contactEmail were not UTF-8 encoded.",
+			""
+		);
+	}
+
 	return &_error( "Malformed authURI - must not have an http:// prefix", "" )
 	  if $auth =~ '[/:]';
 	return &_error( "Malformed authURI - must take the form NNN.NNN.NNN", "" )
@@ -1315,10 +1337,12 @@
 	$error .= "missing serviceType \n" unless defined $serviceType;
 	$error .= "invalid character string for serviceName.  Must start with a letter followed by [A-Za-z0-9_]\n" if ($serviceName =~ /^[^A-Za-z]/);
 	$error .= "invalid character string for serviceName.  Must start with a letter followed by [A-Za-z0-9_]\n" if ($serviceName =~ /^.+?[^A-Za-z0-9_]/);
-	
+
 	#	$error .="missing signatureURL \n" unless defined $signatureURL;
 	$error .= "missing authURI \n"      unless defined $AuthURI;
+	$error .= "invalid character encoding; authURI not encoded as UTF-8\n" unless decode_utf8( $AuthURI ) eq $AuthURI;
 	$error .= "missing contactEmail \n" unless defined $contactEmail;
+	$error .= "invalid character encoding; contactEmail not encoded as UTF-8\n" unless decode_utf8( $contactEmail ) eq $contactEmail;
 	return &_error( "Malformed authURI - must not have an http:// prefix", "" )
 	  if $AuthURI =~ '[/:]';
 	return &_error( "Malformed authURI - must take the form NNN.NNN.NNN", "" )
@@ -1326,8 +1350,11 @@
 	return &_error("Malformed email - must be a valid email address of the form name\@organization.foo","")
 	  unless $contactEmail =~ /\S\@\S+\.\S+/;
 	$error .= "missing URL \n"         unless defined $URL;
+	$error .= "invalid character encoding; URL not encoded as UTF-8\n" unless decode_utf8( $URL ) eq $URL;
 	$error .= "missing description \n" unless defined $desc;
+	$error .= "invalid character encoding; description not encoded as UTF-8\n" unless decode_utf8( $desc ) eq $desc;
 	$error .= "missing Category \n"    unless defined $Category;
+	$error .= "invalid character encoding; service name not encoded as UTF-8\n" unless decode_utf8( $serviceName ) eq $serviceName;
 	return &_error( "malformed payload $error\n\n", "" ) if ($error);
 	return &_error(
 		"Category may take the (case sensitive) values 'moby', 'moby-async', 'cgi', 'doc-literal', and 'doc-literal-async', \n",
@@ -1494,11 +1521,15 @@
 	return (-1,"Invalid articlename name found. Articlenames may not contain spaces or other special characters.") 
 			 if $article =~ /([\+\=:\s\&\<\>\[\]\^\`\{\|\}\~\(\)\\\/\$\#\@\,\|\?\.!\*\;\'\"])/;
 	
+	#check encoding for those articles that are not the empty string or a string of whitespace
+	return (-1,"Invalid character encoding; articlename not UTF-8 encoded.") 
+		 unless decode_utf8( $article ) eq $article;
+
 	$debug && &_LOG("ARTICLENAME in _registerArticle is $article");
 	if (lc($inout) eq "input"){
 	    return (-1, "Input Simples and collections are required to have an articleName as of API version 0.86") if (!$article && !$collid);
 	}
-	
+
 	my ( $object_type, @namespaces );
 	if ( $simp_coll eq "Collection" ) {
 		$debug && &_LOG("Collection!\n");




More information about the MOBY-guts mailing list