File tree Expand file tree Collapse file tree
main/java/org/sejda/sambox/cos
test/java/org/sejda/sambox/cos Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ public static String toString(byte[] bytes)
144144 */
145145 public static byte [] getBytes (String text )
146146 {
147- if (nonNull (text ))
147+ if (nonNull (text ) && ! text . isEmpty () )
148148 {
149149 try (var out = new FastByteArrayOutputStream (text .length ()))
150150 {
Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ public void testDeviations()
9393 }
9494
9595 @ Test
96- public void nullSafe () throws IOException
96+ public void nullSafe ()
9797 {
9898 var sb = new StringBuilder ("Chuck" );
9999 sb .append ((char ) 0x18 );
@@ -103,6 +103,18 @@ public void nullSafe() throws IOException
103103 assertNull (PDFDocEncoding .getBytes (sb .toString ()));
104104 }
105105
106+ @ Test
107+ public void nullText ()
108+ {
109+ assertNull (PDFDocEncoding .getBytes (null ));
110+ }
111+
112+ @ Test
113+ public void blankSafe ()
114+ {
115+ assertNull (PDFDocEncoding .getBytes ("" ));
116+ }
117+
106118 /**
107119 * PDFBOX-3864: Test that chars smaller than 256 which are NOT part of PDFDocEncoding are
108120 * handled correctly.
You can’t perform that action at this time.
0 commit comments