mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-11-07 22:44:21 +00:00
* ExtractorXML.java
shouldExtract() - use getContentReplayPrefixString() for <?xml check
This commit is contained in:
1 parent
a2eaa9d6ac
commit
c9c74b5c28
1 file changed
+7
-13
@@ -77,19 +77,13 @@ public class ExtractorXML extends ContentExtractor {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
// check if content starts with xml preamble "<?xml" and does not
|
||||
// contain "<!doctype html" or "<html" early in the content
|
||||
ReplayCharSequence cs = curi.getRecorder().getContentReplayCharSequence();
|
||||
String contentStartingChunk = cs.subSequence(0, Math.min(cs.length(), 400)).toString();
|
||||
if (contentStartingChunk.matches("(?is)[\\ufeff]?<\\?xml\\s.*")
|
||||
&& !contentStartingChunk.matches("(?is).*(?:<!doctype\\s+html|<html[>\\s]).*")) {
|
||||
return true;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.severe(curi + " - failed getting ReplayCharSequence: " + e);
|
||||
return false;
|
||||
}
|
||||
// check if content starts with xml preamble "<?xml" and does not
|
||||
// contain "<!doctype html" or "<html" early in the content
|
||||
String contentStartingChunk = curi.getRecorder().getContentReplayPrefixString(400);
|
||||
if (contentStartingChunk.matches("(?is)[\\ufeff]?<\\?xml\\s.*")
|
||||
&& !contentStartingChunk.matches("(?is).*(?:<!doctype\\s+html|<html[>\\s]).*")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user