Skip to content

Commit

Permalink
[RELEASE] iText 7 Core - 7.1.16
Browse files Browse the repository at this point in the history
https://github.com/itext/itext7/releases/tag/7.1.16

* release_branch_DEVSIX-5154:
  [RELEASE] 7.1.16
  Make EventData building based on IEvent synchronization independent from factory instance
  Perform scheduled check based on latest acquired Version instance
  Remove TODO related to already closed DEVSIX-5049
  Add support of attr() with type for url and string Add support of attr() with fallback for url and string Add support of attr() in target-counter Add tests
  Add missing copyright headers
  SVG: Add possibility to customize renderers for text chunks
  Prepare TargetCounterHandler to used from pure layout code
  Fix margin-border-padding widths for floating Text min-max-width calculation
  Rename #createDocument to #createDummyDocument in RendererUnitTest
  Fix some confusing Javadoc about OCSP
  Add DEVSIX reference to TODOs in tagging utilities for proper tags removal
  Improve StructTreeRoot documentation
  Improve GhostScript and ImageMagick util classes formatting and their tests
  Relax fuzziness parameter for ImageMagickHelper test
  Simplify ghostscript util test for -dSAFER command
  Replace ExpectedException.none to Assert.assertThrows
  Add support processing inline image with ICCBased color space in resources
  Add missing copyright headers
  Improve code coverage
  Add missing copyright headers
  Refactor preClose method in PdfSigner
  Add integration test for handling signatures with not merged widgets
  Add missing copyright headers
  Replace html2pdf-private tests: CssStyleAttributeParseTest
  Improve javadocs of TextRenderer
  Fix constructor of PdfReader to close() the PdfTokenizer when exception thrown Add PdfWriter/PdfReader/PdfDocument constructors to try-with-resources Add tests to compareLinkAnnotation method and encrypt method
  Improve javadocs for new code in Type3Font handling
  Set typo ascender/descender for type3 fonts based on font dictionary
  Remove TODOs from PdfTrueTypeFont class
  Cover AnnotationDefaultAppearance and PdfAction with documentation
  Cover Pdf3DAnnotation with javadocs
  Add missing copyright headers
  Support encrypting embedded files only
  Improve the security of XML parsers
  Remove DTDs with non-existent reference from patterns in hyph module
  Add some tests on TextRenderer extensions. Add appropriate documentation.
  Log a message in case getNextRenderer is not overridden in an extended class. Improve its javadoc
  Improve FontSelector with comparing font weights
  Fix rounded border logic in layout
  Introduce lazy initialization for some of pdfDocument fields
  Remove redundant todo from deprecated method
  Add ImageTypeDetector's stream overload
  Implement unicode encoding for producer line in PDF
  Remove redundant mentions of SvgRegexUtils class
  Introduce support of intrinsic aspect ratio in flex algorithm
  [AFTER RELEASE] 7.1.15
  Remove Maven plugins: CheckStyle, PMD, SpotBugs
  Add tests on cells with big rowspan issues
  Add functionality to compare pdf signatures in tests
  Improve CssTypesValidation documentation
  Add tests to increase CrlClientOnline code coverage
  Get rid of new javadoc warnings
  Fix javadoc source version
  Upgrade verapdf-validation-model to 1.18.2
  • Loading branch information
iText-CI committed Jun 17, 2021
2 parents bf84f8a + ab326e8 commit 87fffa6
Show file tree
Hide file tree
Showing 622 changed files with 8,804 additions and 3,911 deletions.
2 changes: 1 addition & 1 deletion barcodes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.itextpdf</groupId>
<artifactId>root</artifactId>
<version>7.1.15</version>
<version>7.1.16</version>
</parent>
<artifactId>barcodes</artifactId>
<name>iText 7 - barcodes</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,19 @@ This file is part of the iText (R) project.
import com.itextpdf.kernel.utils.CompareTool;
import com.itextpdf.test.ExtendedITextTest;
import com.itextpdf.test.annotations.type.IntegrationTest;

import java.io.IOException;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.ExpectedException;

@Category(IntegrationTest.class)
public class BarcodeDataMatrixTest extends ExtendedITextTest {

public static final String destinationFolder = "./target/test/com/itextpdf/barcodes/BarcodeDataMatrix/";
public static final String sourceFolder = "./src/test/resources/com/itextpdf/barcodes/";

@Rule
public ExpectedException junitExpectedException = ExpectedException.none();

@BeforeClass
public static void beforeClass() {
createOrClearDestinationFolder(destinationFolder);
Expand Down Expand Up @@ -191,6 +187,7 @@ public void barcode07Test() {
String aCode = "aBCdeFG12";

int result = bc.setCode(aCode);

Assert.assertEquals(result, BarcodeDataMatrix.DM_ERROR_TEXT_TOO_BIG);
}

Expand All @@ -200,6 +197,7 @@ public void barcode08Test() {
barcodeDataMatrix.setWidth(18);
barcodeDataMatrix.setHeight(18);
int result = barcodeDataMatrix.setCode("AbcdFFghijklmnopqrstuWXSQ");

Assert.assertEquals(BarcodeDataMatrix.DM_ERROR_TEXT_TOO_BIG, result);
}

Expand All @@ -209,6 +207,7 @@ public void barcode09Test() {
barcodeDataMatrix.setWidth(17);
barcodeDataMatrix.setHeight(17);
int result = barcodeDataMatrix.setCode("AbcdFFghijklmnopqrstuWXSQ");

Assert.assertEquals(BarcodeDataMatrix.DM_ERROR_INVALID_SQUARE, result);
}

Expand All @@ -218,6 +217,7 @@ public void barcode10Test() {
barcodeDataMatrix.setWidth(26);
barcodeDataMatrix.setHeight(12);
int result = barcodeDataMatrix.setCode("AbcdFFghijklmnopqrstuWXSQ");

Assert.assertEquals(BarcodeDataMatrix.DM_ERROR_TEXT_TOO_BIG, result);
}

Expand All @@ -228,37 +228,38 @@ public void barcode11Test() {
barcodeDataMatrix.setHeight(18);
byte[] str = "AbcdFFghijklmnop".getBytes();
int result = barcodeDataMatrix.setCode(str, 0, str.length);

Assert.assertEquals(BarcodeDataMatrix.DM_NO_ERROR, result);
}

@Test
public void barcode12Test() {
junitExpectedException.expect(IndexOutOfBoundsException.class);
BarcodeDataMatrix barcodeDataMatrix = new BarcodeDataMatrix();
barcodeDataMatrix.setWidth(18);
barcodeDataMatrix.setHeight(18);
byte[] str = "AbcdFFghijklmnop".getBytes();
barcodeDataMatrix.setCode(str, -1, str.length);

Exception e = Assert.assertThrows(IndexOutOfBoundsException.class, () -> barcodeDataMatrix.setCode(str, -1, str.length));
}

@Test
public void barcode13Test() {
junitExpectedException.expect(IndexOutOfBoundsException.class);
BarcodeDataMatrix barcodeDataMatrix = new BarcodeDataMatrix();
barcodeDataMatrix.setWidth(18);
barcodeDataMatrix.setHeight(18);
byte[] str = "AbcdFFghijklmnop".getBytes();
barcodeDataMatrix.setCode(str, 0, str.length + 1);

Assert.assertThrows(IndexOutOfBoundsException.class, () -> barcodeDataMatrix.setCode(str, 0, str.length + 1));
}

@Test
public void barcode14Test() {
junitExpectedException.expect(IndexOutOfBoundsException.class);
BarcodeDataMatrix barcodeDataMatrix = new BarcodeDataMatrix();
barcodeDataMatrix.setWidth(18);
barcodeDataMatrix.setHeight(18);
byte[] str = "AbcdFFghijklmnop".getBytes();
barcodeDataMatrix.setCode(str, 0, -1);

Assert.assertThrows(IndexOutOfBoundsException.class, () -> barcodeDataMatrix.setCode(str, 0, -1));
}

@Test
Expand All @@ -268,6 +269,7 @@ public void barcode15Test() {
barcodeDataMatrix.setHeight(18);
byte[] str = "AbcdFFghijklmnop".getBytes();
int result = barcodeDataMatrix.setCode(str, str.length, 0);

Assert.assertEquals(BarcodeDataMatrix.DM_NO_ERROR, result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,14 @@ This file is part of the iText (R) project.

import java.io.ByteArrayOutputStream;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.ExpectedException;

@Category(UnitTest.class)
public class BarcodeEANUnitTest extends ExtendedITextTest {

public static final float EPS = 0.0001f;

@Rule
public ExpectedException junitExpectedException = ExpectedException.none();

@Test
public void calculateEANParityTest() throws PdfException {
int expectedParity = BarcodeEAN.calculateEANParity("1234567890");
Expand Down Expand Up @@ -227,9 +222,6 @@ public void getBarcodeSizeSUPP2Test() throws PdfException {

@Test
public void getBarcodeSizeIncorrectTypeTest() throws PdfException {
junitExpectedException.expect(PdfException.class);
junitExpectedException.expectMessage("Invalid code type");

PdfDocument document = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()));

Barcode1D barcode = new BarcodeEAN(document);
Expand All @@ -239,6 +231,7 @@ public void getBarcodeSizeIncorrectTypeTest() throws PdfException {
barcode.setCodeType(1234);

// We do expect an exception here
barcode.getBarcodeSize();
Exception e = Assert.assertThrows(PdfException.class, () -> barcode.getBarcodeSize());
Assert.assertEquals("Invalid code type", e.getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ This file is part of the iText (R) project.
import java.io.IOException;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.ExpectedException;

@Category(IntegrationTest.class)
public class BarcodePDF417Test extends ExtendedITextTest {
Expand All @@ -77,9 +75,6 @@ public static void beforeClass() {
createDestinationFolder(destinationFolder);
}

@Rule
public ExpectedException junitExpectedException = ExpectedException.none();

@Test
public void barcode01Test() throws IOException, PdfException, InterruptedException {
String filename = "barcode417_01.pdf";
Expand Down Expand Up @@ -440,9 +435,6 @@ public void barcode417OptionsWithBarcodeGenerationTest() {

@Test
public void barcode417OptionsWithBarcodeGenerationInvalidSizeTest() {
junitExpectedException.expect(PdfException.class);
junitExpectedException.expectMessage("Invalid codeword size.");

ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter writer = new PdfWriter(baos);
PdfDocument document = new PdfDocument(writer);
Expand All @@ -452,8 +444,11 @@ public void barcode417OptionsWithBarcodeGenerationInvalidSizeTest() {

BarcodePDF417 barcode = new BarcodePDF417();
barcode.setOptions(64);
barcode.placeBarcode(canvas, null);

Exception e = Assert.assertThrows(PdfException.class,
() -> barcode.placeBarcode(canvas, null)
);
Assert.assertEquals("Invalid codeword size.", e.getMessage());
Assert.assertEquals(64, barcode.getOptions());
}

Expand Down
2 changes: 1 addition & 1 deletion font-asian/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.itextpdf</groupId>
<artifactId>root</artifactId>
<version>7.1.15</version>
<version>7.1.16</version>
</parent>
<artifactId>font-asian</artifactId>
<name>iText 7 - Asian fonts</name>
Expand Down
2 changes: 1 addition & 1 deletion forms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.itextpdf</groupId>
<artifactId>root</artifactId>
<version>7.1.15</version>
<version>7.1.16</version>
</parent>
<artifactId>forms</artifactId>
<name>iText 7 - forms</name>
Expand Down
41 changes: 11 additions & 30 deletions forms/src/main/java/com/itextpdf/forms/xfa/XfaForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,24 @@ This file is part of the iText (R) project.
import com.itextpdf.kernel.pdf.PdfString;
import com.itextpdf.kernel.pdf.PdfVersion;
import com.itextpdf.kernel.pdf.VersionConforming;
import com.itextpdf.kernel.utils.XmlProcessorCreator;
import com.itextpdf.kernel.xmp.XmlDomWriter;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

Expand Down Expand Up @@ -107,13 +103,14 @@ public XfaForm() {

/**
* Creates an XFA form by the stream containing all xml information
*
* @param inputStream the InputStream
*/
public XfaForm(InputStream inputStream) {
try {
initXfaForm(inputStream);
} catch (Exception e) {
throw new PdfException(e);
throw new PdfException(e.getMessage(), e);
}
}

Expand All @@ -140,7 +137,7 @@ public XfaForm(PdfDictionary acroFormDictionary) {
try {
initXfaForm(xfa);
} catch (Exception e) {
throw new PdfException(e);
throw new PdfException(e.getMessage(), e);
}
}
}
Expand All @@ -157,7 +154,7 @@ public XfaForm(PdfDocument pdfDocument) {
try {
initXfaForm(xfa);
} catch (Exception e) {
throw new PdfException(e);
throw new PdfException(e.getMessage(), e);
}
}
}
Expand Down Expand Up @@ -497,17 +494,12 @@ public void fillXfaForm(InputSource is) throws IOException {
* @throws java.io.IOException if any I/O issue occurs on the {@link InputSource}
*/
public void fillXfaForm(InputSource is, boolean readOnly) throws IOException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db;
try {
db = dbf.newDocumentBuilder();
db.setEntityResolver(new SafeEmptyEntityResolver());
DocumentBuilder db = XmlProcessorCreator.createSafeDocumentBuilder(false, false);
Document newdoc = db.parse(is);
fillXfaForm(newdoc.getDocumentElement(), readOnly);
} catch (ParserConfigurationException e) {
throw new PdfException(e);
} catch (SAXException e) {
throw new PdfException(e);
throw new PdfException(e.getMessage(), e);
}
}

Expand Down Expand Up @@ -631,11 +623,8 @@ private void initXfaForm(PdfObject xfa) throws IOException, ParserConfigurationE
initXfaForm(new ByteArrayInputStream(bout.toByteArray()));
}

private void initXfaForm(InputStream inputStream) throws ParserConfigurationException, IOException, SAXException {
DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
fact.setNamespaceAware(true);
DocumentBuilder db = fact.newDocumentBuilder();
db.setEntityResolver(new SafeEmptyEntityResolver());
private void initXfaForm(InputStream inputStream) throws IOException, SAXException {
DocumentBuilder db = XmlProcessorCreator.createSafeDocumentBuilder(true, false);
setDomDocument(db.parse(inputStream));
xfaPresent = true;
}
Expand Down Expand Up @@ -696,12 +685,4 @@ private Node findDataNode(Node datasetsNode) {
}
return null;
}

// Prevents XXE attacks
private static class SafeEmptyEntityResolver implements EntityResolver {
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
return new InputSource(new StringReader(""));
}
}

}
Loading

0 comments on commit 87fffa6

Please sign in to comment.