Skip to content

Commit 87fffa6

Browse files
committed
[RELEASE] iText 7 Core - 7.1.16
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
2 parents bf84f8a + ab326e8 commit 87fffa6

File tree

622 files changed

+8804
-3911
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

622 files changed

+8804
-3911
lines changed

barcodes/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.itextpdf</groupId>
66
<artifactId>root</artifactId>
7-
<version>7.1.15</version>
7+
<version>7.1.16</version>
88
</parent>
99
<artifactId>barcodes</artifactId>
1010
<name>iText 7 - barcodes</name>

barcodes/src/test/java/com/itextpdf/barcodes/BarcodeDataMatrixTest.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,19 @@ This file is part of the iText (R) project.
5252
import com.itextpdf.kernel.utils.CompareTool;
5353
import com.itextpdf.test.ExtendedITextTest;
5454
import com.itextpdf.test.annotations.type.IntegrationTest;
55+
5556
import java.io.IOException;
5657
import org.junit.Assert;
5758
import org.junit.BeforeClass;
58-
import org.junit.Rule;
5959
import org.junit.Test;
6060
import org.junit.experimental.categories.Category;
61-
import org.junit.rules.ExpectedException;
6261

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

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

69-
@Rule
70-
public ExpectedException junitExpectedException = ExpectedException.none();
71-
7268
@BeforeClass
7369
public static void beforeClass() {
7470
createOrClearDestinationFolder(destinationFolder);
@@ -191,6 +187,7 @@ public void barcode07Test() {
191187
String aCode = "aBCdeFG12";
192188

193189
int result = bc.setCode(aCode);
190+
194191
Assert.assertEquals(result, BarcodeDataMatrix.DM_ERROR_TEXT_TOO_BIG);
195192
}
196193

@@ -200,6 +197,7 @@ public void barcode08Test() {
200197
barcodeDataMatrix.setWidth(18);
201198
barcodeDataMatrix.setHeight(18);
202199
int result = barcodeDataMatrix.setCode("AbcdFFghijklmnopqrstuWXSQ");
200+
203201
Assert.assertEquals(BarcodeDataMatrix.DM_ERROR_TEXT_TOO_BIG, result);
204202
}
205203

@@ -209,6 +207,7 @@ public void barcode09Test() {
209207
barcodeDataMatrix.setWidth(17);
210208
barcodeDataMatrix.setHeight(17);
211209
int result = barcodeDataMatrix.setCode("AbcdFFghijklmnopqrstuWXSQ");
210+
212211
Assert.assertEquals(BarcodeDataMatrix.DM_ERROR_INVALID_SQUARE, result);
213212
}
214213

@@ -218,6 +217,7 @@ public void barcode10Test() {
218217
barcodeDataMatrix.setWidth(26);
219218
barcodeDataMatrix.setHeight(12);
220219
int result = barcodeDataMatrix.setCode("AbcdFFghijklmnopqrstuWXSQ");
220+
221221
Assert.assertEquals(BarcodeDataMatrix.DM_ERROR_TEXT_TOO_BIG, result);
222222
}
223223

@@ -228,37 +228,38 @@ public void barcode11Test() {
228228
barcodeDataMatrix.setHeight(18);
229229
byte[] str = "AbcdFFghijklmnop".getBytes();
230230
int result = barcodeDataMatrix.setCode(str, 0, str.length);
231+
231232
Assert.assertEquals(BarcodeDataMatrix.DM_NO_ERROR, result);
232233
}
233234

234235
@Test
235236
public void barcode12Test() {
236-
junitExpectedException.expect(IndexOutOfBoundsException.class);
237237
BarcodeDataMatrix barcodeDataMatrix = new BarcodeDataMatrix();
238238
barcodeDataMatrix.setWidth(18);
239239
barcodeDataMatrix.setHeight(18);
240240
byte[] str = "AbcdFFghijklmnop".getBytes();
241-
barcodeDataMatrix.setCode(str, -1, str.length);
241+
242+
Exception e = Assert.assertThrows(IndexOutOfBoundsException.class, () -> barcodeDataMatrix.setCode(str, -1, str.length));
242243
}
243244

244245
@Test
245246
public void barcode13Test() {
246-
junitExpectedException.expect(IndexOutOfBoundsException.class);
247247
BarcodeDataMatrix barcodeDataMatrix = new BarcodeDataMatrix();
248248
barcodeDataMatrix.setWidth(18);
249249
barcodeDataMatrix.setHeight(18);
250250
byte[] str = "AbcdFFghijklmnop".getBytes();
251-
barcodeDataMatrix.setCode(str, 0, str.length + 1);
251+
252+
Assert.assertThrows(IndexOutOfBoundsException.class, () -> barcodeDataMatrix.setCode(str, 0, str.length + 1));
252253
}
253254

254255
@Test
255256
public void barcode14Test() {
256-
junitExpectedException.expect(IndexOutOfBoundsException.class);
257257
BarcodeDataMatrix barcodeDataMatrix = new BarcodeDataMatrix();
258258
barcodeDataMatrix.setWidth(18);
259259
barcodeDataMatrix.setHeight(18);
260260
byte[] str = "AbcdFFghijklmnop".getBytes();
261-
barcodeDataMatrix.setCode(str, 0, -1);
261+
262+
Assert.assertThrows(IndexOutOfBoundsException.class, () -> barcodeDataMatrix.setCode(str, 0, -1));
262263
}
263264

264265
@Test
@@ -268,6 +269,7 @@ public void barcode15Test() {
268269
barcodeDataMatrix.setHeight(18);
269270
byte[] str = "AbcdFFghijklmnop".getBytes();
270271
int result = barcodeDataMatrix.setCode(str, str.length, 0);
272+
271273
Assert.assertEquals(BarcodeDataMatrix.DM_NO_ERROR, result);
272274
}
273275

barcodes/src/test/java/com/itextpdf/barcodes/BarcodeEANUnitTest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,14 @@ This file is part of the iText (R) project.
5151

5252
import java.io.ByteArrayOutputStream;
5353
import org.junit.Assert;
54-
import org.junit.Rule;
5554
import org.junit.Test;
5655
import org.junit.experimental.categories.Category;
57-
import org.junit.rules.ExpectedException;
5856

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

6260
public static final float EPS = 0.0001f;
6361

64-
@Rule
65-
public ExpectedException junitExpectedException = ExpectedException.none();
66-
6762
@Test
6863
public void calculateEANParityTest() throws PdfException {
6964
int expectedParity = BarcodeEAN.calculateEANParity("1234567890");
@@ -227,9 +222,6 @@ public void getBarcodeSizeSUPP2Test() throws PdfException {
227222

228223
@Test
229224
public void getBarcodeSizeIncorrectTypeTest() throws PdfException {
230-
junitExpectedException.expect(PdfException.class);
231-
junitExpectedException.expectMessage("Invalid code type");
232-
233225
PdfDocument document = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()));
234226

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

241233
// We do expect an exception here
242-
barcode.getBarcodeSize();
234+
Exception e = Assert.assertThrows(PdfException.class, () -> barcode.getBarcodeSize());
235+
Assert.assertEquals("Invalid code type", e.getMessage());
243236
}
244237
}

barcodes/src/test/java/com/itextpdf/barcodes/BarcodePDF417Test.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,8 @@ This file is part of the iText (R) project.
6262
import java.io.IOException;
6363
import org.junit.Assert;
6464
import org.junit.BeforeClass;
65-
import org.junit.Rule;
6665
import org.junit.Test;
6766
import org.junit.experimental.categories.Category;
68-
import org.junit.rules.ExpectedException;
6967

7068
@Category(IntegrationTest.class)
7169
public class BarcodePDF417Test extends ExtendedITextTest {
@@ -77,9 +75,6 @@ public static void beforeClass() {
7775
createDestinationFolder(destinationFolder);
7876
}
7977

80-
@Rule
81-
public ExpectedException junitExpectedException = ExpectedException.none();
82-
8378
@Test
8479
public void barcode01Test() throws IOException, PdfException, InterruptedException {
8580
String filename = "barcode417_01.pdf";
@@ -440,9 +435,6 @@ public void barcode417OptionsWithBarcodeGenerationTest() {
440435

441436
@Test
442437
public void barcode417OptionsWithBarcodeGenerationInvalidSizeTest() {
443-
junitExpectedException.expect(PdfException.class);
444-
junitExpectedException.expectMessage("Invalid codeword size.");
445-
446438
ByteArrayOutputStream baos = new ByteArrayOutputStream();
447439
PdfWriter writer = new PdfWriter(baos);
448440
PdfDocument document = new PdfDocument(writer);
@@ -452,8 +444,11 @@ public void barcode417OptionsWithBarcodeGenerationInvalidSizeTest() {
452444

453445
BarcodePDF417 barcode = new BarcodePDF417();
454446
barcode.setOptions(64);
455-
barcode.placeBarcode(canvas, null);
456447

448+
Exception e = Assert.assertThrows(PdfException.class,
449+
() -> barcode.placeBarcode(canvas, null)
450+
);
451+
Assert.assertEquals("Invalid codeword size.", e.getMessage());
457452
Assert.assertEquals(64, barcode.getOptions());
458453
}
459454

font-asian/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.itextpdf</groupId>
66
<artifactId>root</artifactId>
7-
<version>7.1.15</version>
7+
<version>7.1.16</version>
88
</parent>
99
<artifactId>font-asian</artifactId>
1010
<name>iText 7 - Asian fonts</name>

forms/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.itextpdf</groupId>
66
<artifactId>root</artifactId>
7-
<version>7.1.15</version>
7+
<version>7.1.16</version>
88
</parent>
99
<artifactId>forms</artifactId>
1010
<name>iText 7 - forms</name>

forms/src/main/java/com/itextpdf/forms/xfa/XfaForm.java

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -54,28 +54,24 @@ This file is part of the iText (R) project.
5454
import com.itextpdf.kernel.pdf.PdfString;
5555
import com.itextpdf.kernel.pdf.PdfVersion;
5656
import com.itextpdf.kernel.pdf.VersionConforming;
57+
import com.itextpdf.kernel.utils.XmlProcessorCreator;
5758
import com.itextpdf.kernel.xmp.XmlDomWriter;
5859

59-
import javax.xml.parsers.DocumentBuilder;
60-
import javax.xml.parsers.DocumentBuilderFactory;
61-
import javax.xml.parsers.ParserConfigurationException;
62-
6360
import java.io.ByteArrayInputStream;
6461
import java.io.ByteArrayOutputStream;
6562
import java.io.File;
6663
import java.io.FileInputStream;
6764
import java.io.IOException;
6865
import java.io.InputStream;
69-
import java.io.StringReader;
7066
import java.nio.charset.StandardCharsets;
7167
import java.util.HashMap;
7268
import java.util.Map;
73-
69+
import javax.xml.parsers.DocumentBuilder;
70+
import javax.xml.parsers.ParserConfigurationException;
7471
import org.w3c.dom.Document;
7572
import org.w3c.dom.Element;
7673
import org.w3c.dom.Node;
7774
import org.w3c.dom.NodeList;
78-
import org.xml.sax.EntityResolver;
7975
import org.xml.sax.InputSource;
8076
import org.xml.sax.SAXException;
8177

@@ -107,13 +103,14 @@ public XfaForm() {
107103

108104
/**
109105
* Creates an XFA form by the stream containing all xml information
106+
*
110107
* @param inputStream the InputStream
111108
*/
112109
public XfaForm(InputStream inputStream) {
113110
try {
114111
initXfaForm(inputStream);
115112
} catch (Exception e) {
116-
throw new PdfException(e);
113+
throw new PdfException(e.getMessage(), e);
117114
}
118115
}
119116

@@ -140,7 +137,7 @@ public XfaForm(PdfDictionary acroFormDictionary) {
140137
try {
141138
initXfaForm(xfa);
142139
} catch (Exception e) {
143-
throw new PdfException(e);
140+
throw new PdfException(e.getMessage(), e);
144141
}
145142
}
146143
}
@@ -157,7 +154,7 @@ public XfaForm(PdfDocument pdfDocument) {
157154
try {
158155
initXfaForm(xfa);
159156
} catch (Exception e) {
160-
throw new PdfException(e);
157+
throw new PdfException(e.getMessage(), e);
161158
}
162159
}
163160
}
@@ -497,17 +494,12 @@ public void fillXfaForm(InputSource is) throws IOException {
497494
* @throws java.io.IOException if any I/O issue occurs on the {@link InputSource}
498495
*/
499496
public void fillXfaForm(InputSource is, boolean readOnly) throws IOException {
500-
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
501-
DocumentBuilder db;
502497
try {
503-
db = dbf.newDocumentBuilder();
504-
db.setEntityResolver(new SafeEmptyEntityResolver());
498+
DocumentBuilder db = XmlProcessorCreator.createSafeDocumentBuilder(false, false);
505499
Document newdoc = db.parse(is);
506500
fillXfaForm(newdoc.getDocumentElement(), readOnly);
507-
} catch (ParserConfigurationException e) {
508-
throw new PdfException(e);
509501
} catch (SAXException e) {
510-
throw new PdfException(e);
502+
throw new PdfException(e.getMessage(), e);
511503
}
512504
}
513505

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

634-
private void initXfaForm(InputStream inputStream) throws ParserConfigurationException, IOException, SAXException {
635-
DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
636-
fact.setNamespaceAware(true);
637-
DocumentBuilder db = fact.newDocumentBuilder();
638-
db.setEntityResolver(new SafeEmptyEntityResolver());
626+
private void initXfaForm(InputStream inputStream) throws IOException, SAXException {
627+
DocumentBuilder db = XmlProcessorCreator.createSafeDocumentBuilder(true, false);
639628
setDomDocument(db.parse(inputStream));
640629
xfaPresent = true;
641630
}
@@ -696,12 +685,4 @@ private Node findDataNode(Node datasetsNode) {
696685
}
697686
return null;
698687
}
699-
700-
// Prevents XXE attacks
701-
private static class SafeEmptyEntityResolver implements EntityResolver {
702-
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
703-
return new InputSource(new StringReader(""));
704-
}
705-
}
706-
707688
}

0 commit comments

Comments
 (0)