Skip to content

Commit e43519e

Browse files
committed
DefaultEntityResolver: more informative error message for invalid types.
1 parent 688eaec commit e43519e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/io/sf/carte/doc/xml/dtd/DefaultEntityResolver.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,16 @@ public final InputSource resolveEntity(String name, String publicId, String base
370370
if (con instanceof HttpURLConnection) {
371371
((HttpURLConnection) con).disconnect();
372372
}
373-
throw new SAXException("Invalid url: " + enturl.toExternalForm());
373+
String msg = enturl.toExternalForm();
374+
if (conType != null) {
375+
// Sanitize untrusted content-type by removing control characters
376+
// ('Other, Control' unicode category).
377+
conType = conType.replaceAll("\\p{Cc}", "*CTRL*");
378+
msg = "URL served with invalid type (" + conType + "): " + msg;
379+
} else {
380+
msg = "URL served with invalid type: " + msg;
381+
}
382+
throw new SAXException(msg);
374383
}
375384
isrc = new InputSource();
376385
isrc.setSystemId(enturl.toExternalForm());

0 commit comments

Comments
 (0)