aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libqpdf/QPDF_String.cc22
-rw-r--r--qpdf/qtest/qpdf/encrypted1.out4
-rw-r--r--qpdf/qtest/qpdf/good13.out2
-rw-r--r--qpdf/qtest/qpdf/good13.qdf16
-rw-r--r--qpdf/qtest/qpdf/good14.out2
-rw-r--r--qpdf/qtest/qpdf/good9.qdf2
-rw-r--r--qpdf/qtest/qpdf/show-xref-by-id.out2
7 files changed, 26 insertions, 24 deletions
diff --git a/libqpdf/QPDF_String.cc b/libqpdf/QPDF_String.cc
index 69c2ecb7..274b2375 100644
--- a/libqpdf/QPDF_String.cc
+++ b/libqpdf/QPDF_String.cc
@@ -9,6 +9,10 @@
#include <string.h>
// See above about ctype.
+static bool is_ascii_printable(unsigned char ch)
+{
+ return ((ch >= 32) && (ch <= 126));
+}
static bool is_iso_latin1_printable(unsigned char ch)
{
return (((ch >= 32) && (ch <= 126)) || (ch >= 160));
@@ -40,12 +44,13 @@ QPDF_String::unparse(bool force_binary)
for (unsigned int i = 0; i < this->val.length(); ++i)
{
char ch = this->val[i];
- // Note: do not use locale to determine printability. The PDF
- // specification accepts arbitrary binary data. Some locales
- // imply multibyte characters. We'll consider something
- // printable if it is printable in ISO-Latin-1. We'll code
- // this manually rather than being rude and setting locale.
- if ((ch == 0) || (! (is_iso_latin1_printable(ch) ||
+ // Note: do not use locale to determine printability. The
+ // PDF specification accepts arbitrary binary data. Some
+ // locales imply multibyte characters. We'll consider
+ // something printable if it is printable in 7-bit ASCII.
+ // We'll code this manually rather than being rude and
+ // setting locale.
+ if ((ch == 0) || (! (is_ascii_printable(ch) ||
strchr("\n\r\t\b\f", ch))))
{
++nonprintable;
@@ -64,10 +69,7 @@ QPDF_String::unparse(bool force_binary)
}
// Use hex notation if more than 20% of the characters are not
- // printable in the current locale. Uniformly distributed random
- // characters will not pass this test even with ISO-Latin-1 in
- // which 76% are either printable or in the set of standard
- // escaped characters.
+ // printable in plain ASCII.
if (5 * nonprintable > val.length())
{
use_hexstring = true;
diff --git a/qpdf/qtest/qpdf/encrypted1.out b/qpdf/qtest/qpdf/encrypted1.out
index f3946c2f..99102b9d 100644
--- a/qpdf/qtest/qpdf/encrypted1.out
+++ b/qpdf/qtest/qpdf/encrypted1.out
@@ -1,7 +1,7 @@
D:20000914005716
Acrobat Distiller 4.05 for Windows
-(hs[¨.<7µ¸"\205\020º~?ö¥zßù\220\024\203Þ#W\230\214\nBªH)
-(ó*Øý¢¬:F\027\21177\nov\007\031 I\235­\205\n\225ñw¹\b\233n Ê)
+<68735ba82e3c37b5b8228510ba7e3ff6a57adff9901483de2357988c0a42aa48>
+<f32ad8fda2ac3a46178937370a6f76071920499dad850a95f177b9089b6e20ca>
1 g
/GS1 gs
1 i
diff --git a/qpdf/qtest/qpdf/good13.out b/qpdf/qtest/qpdf/good13.out
index a75f68c5..a50358cb 100644
--- a/qpdf/qtest/qpdf/good13.out
+++ b/qpdf/qtest/qpdf/good13.out
@@ -5,5 +5,5 @@
/nesting is direct
/strings is direct
unparse: 7 0 R
-unparseResolved: << /hex#20strings [ (Potato) <01020300040560> (AB) ] /indirect 8 0 R /nesting << /a [ 1 2 << /x (y) >> [ (z) ] ] /b << / (legal) /a [ 1 2 ] >> >> /strings [ (one) ($¢) () (\(\)) (\() (\)) (a\f\b\t\r\nb) <410042> (a\nb) (a b) ] >>
+unparseResolved: << /hex#20strings [ (Potato) <01020300040560> (AB) ] /indirect 8 0 R /nesting << /a [ 1 2 << /x (y) >> [ (z) ] ] /b << / (legal) /a [ 1 2 ] >> >> /strings [ (one) <24a2> () (\(\)) (\() (\)) (a\f\b\t\r\nb) <410042> (a\nb) (a b) ] >>
test 1 done
diff --git a/qpdf/qtest/qpdf/good13.qdf b/qpdf/qtest/qpdf/good13.qdf
index 5ad87bb8..f8993a83 100644
--- a/qpdf/qtest/qpdf/good13.qdf
+++ b/qpdf/qtest/qpdf/good13.qdf
@@ -40,7 +40,7 @@ endobj
>>
/strings [
(one)
- ($¢)
+ <24a2>
()
(\(\))
(\()
@@ -129,12 +129,12 @@ xref
0000000000 65535 f
0000000052 00000 n
0000000133 00000 n
-0000000576 00000 n
-0000000685 00000 n
-0000000927 00000 n
-0000001026 00000 n
-0000001072 00000 n
-0000001217 00000 n
+0000000578 00000 n
+0000000687 00000 n
+0000000929 00000 n
+0000001028 00000 n
+0000001074 00000 n
+0000001219 00000 n
trailer <<
/QTest 2 0 R
/Root 1 0 R
@@ -142,5 +142,5 @@ trailer <<
/ID [<31415926535897932384626433832795><31415926535897932384626433832795>]
>>
startxref
-1252
+1254
%%EOF
diff --git a/qpdf/qtest/qpdf/good14.out b/qpdf/qtest/qpdf/good14.out
index c8e5fc9b..d0b2b788 100644
--- a/qpdf/qtest/qpdf/good14.out
+++ b/qpdf/qtest/qpdf/good14.out
@@ -12,7 +12,7 @@ three lines
(\001B%DEF)<01>
<8a8b>
(ab)
-<8c>(Ý) ) >
+<8c><dd> ) >
<610062> (MOO)
-- stream 1 --
This stream does end with a newline.
diff --git a/qpdf/qtest/qpdf/good9.qdf b/qpdf/qtest/qpdf/good9.qdf
index f6c625ad..94d4a0db 100644
--- a/qpdf/qtest/qpdf/good9.qdf
+++ b/qpdf/qtest/qpdf/good9.qdf
@@ -95,7 +95,7 @@ trailer <<
/QTest (¡Hola!)
/Root 1 0 R
/Size 8
- /Z ('\236yÔ\005\037ãjø׸B^Q\n\2139\224\rD|kã¢JZm:½l\231\002\\)
+ /Z <279e79d4051fe36af8d7b8425e510a8b39940d447c6be3a24a5a6d3abd6c99025c>
/ID [<31415926535897932384626433832795><31415926535897932384626433832795>]
>>
startxref
diff --git a/qpdf/qtest/qpdf/show-xref-by-id.out b/qpdf/qtest/qpdf/show-xref-by-id.out
index 62faf0ce..025a2826 100644
--- a/qpdf/qtest/qpdf/show-xref-by-id.out
+++ b/qpdf/qtest/qpdf/show-xref-by-id.out
@@ -1,2 +1,2 @@
Object is stream. Dictionary:
-<< /DecodeParms << /Columns 4 /Predictor 12 >> /Encrypt 11 0 R /Filter /FlateDecode /ID [ (ª&\237þÂ\226±?>ø5ª¡:\n\b) (ím\023\021OµUt\bµ\026Ê9'\025\033) ] /Info 3 0 R /Length 52 /Root 1 0 R /Size 13 /Type /XRef /W [ 1 2 1 ] >>
+<< /DecodeParms << /Columns 4 /Predictor 12 >> /Encrypt 11 0 R /Filter /FlateDecode /ID [ <aa269ffec296b13f3ef835aaa13a0a08> <ed6d13114fb5557408b516ca3927151b> ] /Info 3 0 R /Length 52 /Root 1 0 R /Size 13 /Type /XRef /W [ 1 2 1 ] >>