Two more NullPointerExceptions

Hi,

I'd like to share with you some lines I've had to fix to run mobileok 
without problems:


A. Class HTTPXHTMLResource

In the validateMarkup and validateMobile methods, calls to getBody() 
cause a NullPointerException when the body property is null :

xmlReader.parse(new InputSource(new StringReader(getBody())));

Maybe a check could be added:

String body = getBody();
if (body != null) {
	xmlReader.parse(new InputSource(new StringReader(body)));
}


B. Class HTTPXHTMLResource

In the extractImages method, if the srcAttribute is null, it causes a 
NullPointerException :

final Node srcAttribute = node.getAttributes().getNamedItem("src");
// TODO look for right kind of links
try {
	uris.add(new URI(srcAttribute.getNodeValue()));
} catch ...
}

Maybe a check could also be added:

final Node srcAttribute = node.getAttributes().getNamedItem("src");
if (srcAttribute != null) {
	// TODO look for right kind of links
	try {
		uris.add(new URI(srcAttribute.getNodeValue()));
	} catch ...
	}
}


C. CharacterEncodingSupportTest

When testing pages like
http://www.cheaperthanhotels.co.uk/United-Kingdom/London/Earls-Court/Lord-Jim-Hotel-London-L22244R.htm

That have more than two Content-Type meta tags in the html headers:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

That makes CharacterEncodingSupportTest to fail:

org.w3c.mwi.mobileok.basic.TestException: CharacterEncodingSupportTest 
at 
org.w3c.mwi.mobileok.basic.AbstractXSLTTestImplementation.runTest(AbstractXSLTTestImplementation.java:45)
at
...

Caused by: net.sf.saxon.trans.DynamicError: A sequence of more than one 
item is not allowed as the first argument of lower-case() ("text/html; 
charset=utf-8", "text/html; charset=utf-8")

It is not a very common case, but it'd be great to fix it if possible.


Thank you very much,
--
Guido García Bernardo
IT Deusto

Received on Friday, 30 November 2007 12:23:03 UTC