Skip to content

Commit

Permalink
prep for 1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
tballison committed Jul 25, 2019
1 parent 5215fa6 commit 1158d89
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
26 changes: 25 additions & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -412,4 +412,28 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.

----------------------------------------------
testGZ_quine.gz test file (MIT License)
https://twitter.com/WhoStoleHonno/status/1153315367235784704?s=20

Copyright (c) 2019 by Matthew Barber.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ public abstract class AbstractRecursiveParserWrapperHandler extends DefaultHandl
Property.internalText(TikaCoreProperties.TIKA_META_PREFIX+"embedded_resource_path");

private final ContentHandlerFactory contentHandlerFactory;

private static final int MAX_DEPTH = 100;

private final int maxEmbeddedResources;
private int embeddedResources = 0;
private int embeddedDepth = 0;

public AbstractRecursiveParserWrapperHandler(ContentHandlerFactory contentHandlerFactory) {
this(contentHandlerFactory, -1);
Expand Down Expand Up @@ -82,6 +86,10 @@ public ContentHandler getNewContentHandler(OutputStream os, Charset charset) {
*/
public void startEmbeddedDocument(ContentHandler contentHandler, Metadata metadata) throws SAXException {
embeddedResources++;
embeddedDepth++;
if (embeddedDepth >= MAX_DEPTH) {
throw new SAXException("Max embedded depth reached: "+embeddedDepth);
}
}
/**
* This is called after parsing each embedded document. Override this
Expand All @@ -92,6 +100,7 @@ public void startEmbeddedDocument(ContentHandler contentHandler, Metadata metada
* @throws SAXException
*/
public void endEmbeddedDocument(ContentHandler contentHandler, Metadata metadata) throws SAXException {
embeddedDepth--;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

import org.apache.commons.compress.compressors.CompressorStreamFactory;
import org.apache.tika.TikaTest;
import org.apache.tika.exception.TikaException;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.metadata.TikaCoreProperties;
import org.apache.tika.mime.MediaType;
Expand Down Expand Up @@ -112,4 +113,14 @@ public void testCoverage() throws Exception {
}
}
}

@Test(expected = TikaException.class)
public void testQuineXHTML() throws Exception {
getXML("testGZ_quine.gz");
}

@Test
public void testQuineRecursive() throws Exception {
getRecursiveMetadata("testGZ_quine.gz");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,5 +227,18 @@ public void testJARDetection() throws Exception {
List<Metadata> metadataList = getRecursiveMetadata("testJAR.jar");
assertEquals("application/java-archive", metadataList.get(0).get(HttpHeaders.CONTENT_TYPE));
}
/*
If we can get permission to add http://alf.nu/s/droste.zip
we can turn these tests on.
@Test
public void testQuineRecursiveParserWrapper() throws Exception {
debug(getRecursiveMetadata("testZIP_quine.zip"));
}
@Test(expected = TikaException.class)
public void testQuine() throws Exception {
getXML("testZIP_quine.zip");
}
*/
}
Binary file not shown.

0 comments on commit 1158d89

Please sign in to comment.