* The default HTML4 whitelist. See the JSON files in this directory for
* the actual definitions.
*/
public static HtmlSchema getDefault(MessageQueue mq) {
if (defaultSchema == null) {
SimpleMessageQueue cacheMq = new SimpleMessageQueue();
URI elSrc = URI.create(
"resource:///com/google/caja/lang/html/"
+ "htmlall-elements.json");
URI attrSrc = URI.create(
"resource:///com/google/caja/lang/html/"
+ "htmlall-attributes.json");
try {
defaultSchema = Pair.pair(
new HtmlSchema(
ConfigUtil.loadWhiteListFromJson(
elSrc, ConfigUtil.RESOURCE_RESOLVER, cacheMq),
ConfigUtil.loadWhiteListFromJson(
attrSrc, ConfigUtil.RESOURCE_RESOLVER, cacheMq)),
cacheMq.getMessages());
// If the default schema is borked, there's not much we can do.
} catch (IOException ex) {
mq.getMessages().addAll(cacheMq.getMessages());
throw new SomethingWidgyHappenedError("Default schema is borked", ex);
} catch (ParseException ex) {
cacheMq.getMessages().add(ex.getCajaMessage());
mq.getMessages().addAll(cacheMq.getMessages());
throw new SomethingWidgyHappenedError("Default schema is borked", ex);
}
}
mq.getMessages().addAll(defaultSchema.b);
return defaultSchema.a;