summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdftext_embeddertest.cpp31
-rw-r--r--testing/resources/bug_921.in64
-rw-r--r--testing/resources/bug_921.pdf74
3 files changed, 169 insertions, 0 deletions
diff --git a/fpdfsdk/fpdftext_embeddertest.cpp b/fpdfsdk/fpdftext_embeddertest.cpp
index 7e8e033ae0..1536c8679b 100644
--- a/fpdfsdk/fpdftext_embeddertest.cpp
+++ b/fpdfsdk/fpdftext_embeddertest.cpp
@@ -494,3 +494,34 @@ TEST_F(FPDFTextEmbeddertest, ToUnicode) {
FPDFText_ClosePage(textpage);
UnloadPage(page);
}
+
+TEST_F(FPDFTextEmbeddertest, Bug_921) {
+ EXPECT_TRUE(OpenDocument("bug_921.pdf"));
+ FPDF_PAGE page = LoadPage(0);
+ EXPECT_TRUE(page);
+
+ FPDF_TEXTPAGE textpage = FPDFText_LoadPage(page);
+ EXPECT_TRUE(textpage);
+
+ static constexpr unsigned int kData[] = {
+ 1095, 1077, 1083, 1086, 1074, 1077, 1095, 1077, 1089, 1082, 1086, 1077,
+ 32, 1089, 1090, 1088, 1072, 1076, 1072, 1085, 1080, 1077, 46, 32};
+ static constexpr int kStartIndex = 238;
+
+ ASSERT_EQ(268, FPDFText_CountChars(textpage));
+ for (size_t i = 0; i < FX_ArraySize(kData); ++i)
+ EXPECT_EQ(kData[i], FPDFText_GetUnicode(textpage, kStartIndex + i));
+
+ unsigned short buffer[FX_ArraySize(kData) + 1];
+ memset(buffer, 0xbd, sizeof(buffer));
+ int count =
+ FPDFText_GetText(textpage, kStartIndex, FX_ArraySize(buffer), buffer);
+ ASSERT_GT(count, 0);
+ ASSERT_EQ(FX_ArraySize(kData) + 1, static_cast<size_t>(count));
+ for (size_t i = 0; i < FX_ArraySize(kData); ++i)
+ EXPECT_EQ(kData[i], buffer[i]);
+ EXPECT_EQ(0, buffer[FX_ArraySize(kData)]);
+
+ FPDFText_ClosePage(textpage);
+ UnloadPage(page);
+}
diff --git a/testing/resources/bug_921.in b/testing/resources/bug_921.in
new file mode 100644
index 0000000000..9c48b2004e
--- /dev/null
+++ b/testing/resources/bug_921.in
@@ -0,0 +1,64 @@
+{{header}}
+{{object 1 0}} <<
+ /Type /Catalog
+ /Pages 2 0 R
+>>
+endobj
+{{object 2 0}} <<
+ /Type /Pages
+ /MediaBox [ 0 0 612 792 ]
+ /Count 1
+ /Kids [ 3 0 R ]
+>>
+endobj
+{{object 3 0}} <<
+ /Type /Page
+ /Parent 2 0 R
+ /Resources <<
+ /Font <<
+ /F0 4 0 R
+ >>
+ >>
+ /Contents 6 0 R
+>>
+endobj
+{{object 4 0}} <<
+ /Type /Font
+ /Subtype /Type0
+ /BaseFont /FooFont
+ /Encoding /Identity-H
+ /DescendantFonts [5 0 R]
+>>
+endobj
+{{object 5 0}} <<
+ /Type /Font
+ /Subtype /CIDFontType2
+ /DW 500
+ /BaseFont /FooFont
+ /CIDSystemInfo <<
+ /Ordering (Identity)
+ /Registry (Adobe)
+ /Supplement 0
+ >>
+>>
+endobj
+{{object 6 0}} <<
+/Length 2784
+>>
+stream
+BT
+3 Tr
+/F0 8 Tf
+1.00 -0.00 0.00 1.00 258.2 99.6 Tm 198.0 Tz [ <0418> ] TJ 11.3 0.0 Td 121.2 Tz [ <0440><0430><0437><0432><0435> ] TJ 27.8 0.0 Td 126.0 Tz [ <043D><0435> ] TJ 14.2 0.0 Td 129.0 Tz [ <0432><044B><0440><0430><0436><0430><0435><0442> ] TJ 45.1 0.0 Td 118.0 Tz [ <0433><043B><0443><0431><043E><043A><043E><0433><043E> ] TJ 46.3 0.0 Td 119.0 Tz [ <0447><0435><043B><043E><0432><0435> ] TJ /F0 9 Tf
+-161.8 -10.3 Td 102.1 Tz [ <0447><0435><0441><043A><043E><0433><043E> ] TJ 36.7 0.0 Td 104.3 Tz [ <0441><0442><0440><0430><0434><0430><043D><0438><044F> ] TJ 46.8 0.0 Td 118.7 Tz [ <043B><0438><0446><043E> ] TJ 25.4 0.0 Td 116.4 Tz [ <041E><0442><0435><043B><043B><043E> ] TJ 34.8 0.0 Td 250.7 Tz [ <2014> ] TJ 15.4 0.0 Td 113.8 Tz [ <041F><043E><043B><044F><043A><043E> ] TJ /F0 8 Tf
+-157.7 -10.3 Td 102.0 Tz [ <0432><0430><002C> ] TJ 18.0 0.0 Td 122.4 Tz [ <043A><043E><0433><0434><0430> ] TJ 30.0 0.0 Td 129.0 Tz [ <043E><043D> ] TJ 16.6 0.0 Td 114.8 Tz [ <0433><043E><0432><043E><0440><0438><0442><003A> ] TJ 41.0 0.0 Td 129.4 Tz [ <00AB><0421><0435><0440><0434><0446><0435> ] TJ 40.8 0.0 Td 138.0 Tz [ <043C><043E><0435> ] TJ 22.3 0.0 Td 120.0 Tz [ <043E><0431><0440><0430> ] TJ /F0 9 Tf
+-168.2 -10.8 Td 104.9 Tz [ <0442><0438><043B><043E><0441><044C> ] TJ 31.9 0.0 Td 128.0 Tz [ <0432> ] TJ 10.8 0.0 Td 102.9 Tz [ <043A><0430><043C><0435><043D><044C><0021> ] TJ 36.0 0.0 Td 119.1 Tz [ <0423><0434><0430><0440><0438><0432> ] TJ 37.0 0.0 Td 125.3 Tz [ <043F><043E> ] TJ 15.8 0.0 Td 101.3 Tz [ <043D><0435><043C><002C> ] TJ 22.1 0.0 Td 117.3 Tz [ <044F> ] TJ 8.9 0.0 Td 124.8 Tz [ <0443><0448><0438><0431><0443> ] TJ /F0 8 Tf
+-162.5 -10.6 Td 115.5 Tz [ <0441><0435><0431><0435> ] TJ 21.6 0.0 Td 120.0 Tz [ <0440><0443><043A><0443><002E> ] TJ 29.0 0.0 Td 156.0 Tz [ <041D><043E> ] TJ 17.0 0.0 Td 107.2 Tz [ <0432><0441><0435><002D><0442><0430><043A><0438> ] TJ 40.6 0.0 Td 136.0 Tz [ <043C><0438><0440> ] TJ 20.9 0.0 Td 132.0 Tz [ <043D><0435> ] TJ 15.1 0.0 Td 120.0 Tz [ <0432><0438><0434><0430><043B> ] TJ 29.8 0.0 Td 112.0 Tz [ <0441><043E><0437> ] TJ -175.4 -10.6 Td 120.0 Tz [ <0434><0430><043D><044C><044F> ] TJ 30.7 0.0 Td 104.1 Tz [ <043F><0440><0435><043B><0435><0441><0442><043D><0435><0439><0021><002E><002E><00BB> ] TJ 64.1 0.0 Td 204.0 Tz [ <0418> ] TJ 16.6 0.0 Td 122.4 Tz [ <0432><043D><043E><0432><044C> ] TJ 33.1 0.0 Td 156.0 Tz [ <043C><044B> ] TJ 21.8 0.0 Td 126.0 Tz [ <0432><0438><0434><0438><043C> ] TJ /F0 9 Tf
+-164.9 -11.0 Td 106.7 Tz [ <0433><043B><0443><0431><043E><043A><043E><0435> ] TJ 43.9 0.0 Td 104.9 Tz [ <0447><0435><043B><043E><0432><0435><0447><0435><0441><043A><043E><0435> ] TJ 62.4 0.0 Td 99.2 Tz [ <0441><0442><0440><0430><0434><0430><043D><0438><0435><002E> ] TJ 50.9 0.0 Td 112.0 Tz [ <041F><043E><0440><0443><0433><0430> ] TJ
+ET
+endstream
+endobj
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
diff --git a/testing/resources/bug_921.pdf b/testing/resources/bug_921.pdf
new file mode 100644
index 0000000000..fb3950e54a
--- /dev/null
+++ b/testing/resources/bug_921.pdf
@@ -0,0 +1,74 @@
+%PDF-1.7
+%���
+1 0 obj <<
+ /Type /Catalog
+ /Pages 2 0 R
+>>
+endobj
+2 0 obj <<
+ /Type /Pages
+ /MediaBox [ 0 0 612 792 ]
+ /Count 1
+ /Kids [ 3 0 R ]
+>>
+endobj
+3 0 obj <<
+ /Type /Page
+ /Parent 2 0 R
+ /Resources <<
+ /Font <<
+ /F0 4 0 R
+ >>
+ >>
+ /Contents 6 0 R
+>>
+endobj
+4 0 obj <<
+ /Type /Font
+ /Subtype /Type0
+ /BaseFont /FooFont
+ /Encoding /Identity-H
+ /DescendantFonts [5 0 R]
+>>
+endobj
+5 0 obj <<
+ /Type /Font
+ /Subtype /CIDFontType2
+ /DW 500
+ /BaseFont /FooFont
+ /CIDSystemInfo <<
+ /Ordering (Identity)
+ /Registry (Adobe)
+ /Supplement 0
+ >>
+>>
+endobj
+6 0 obj <<
+/Length 2784
+>>
+stream
+BT
+3 Tr
+/F0 8 Tf
+1.00 -0.00 0.00 1.00 258.2 99.6 Tm 198.0 Tz [ <0418> ] TJ 11.3 0.0 Td 121.2 Tz [ <0440><0430><0437><0432><0435> ] TJ 27.8 0.0 Td 126.0 Tz [ <043D><0435> ] TJ 14.2 0.0 Td 129.0 Tz [ <0432><044B><0440><0430><0436><0430><0435><0442> ] TJ 45.1 0.0 Td 118.0 Tz [ <0433><043B><0443><0431><043E><043A><043E><0433><043E> ] TJ 46.3 0.0 Td 119.0 Tz [ <0447><0435><043B><043E><0432><0435> ] TJ /F0 9 Tf
+-161.8 -10.3 Td 102.1 Tz [ <0447><0435><0441><043A><043E><0433><043E> ] TJ 36.7 0.0 Td 104.3 Tz [ <0441><0442><0440><0430><0434><0430><043D><0438><044F> ] TJ 46.8 0.0 Td 118.7 Tz [ <043B><0438><0446><043E> ] TJ 25.4 0.0 Td 116.4 Tz [ <041E><0442><0435><043B><043B><043E> ] TJ 34.8 0.0 Td 250.7 Tz [ <2014> ] TJ 15.4 0.0 Td 113.8 Tz [ <041F><043E><043B><044F><043A><043E> ] TJ /F0 8 Tf
+-157.7 -10.3 Td 102.0 Tz [ <0432><0430><002C> ] TJ 18.0 0.0 Td 122.4 Tz [ <043A><043E><0433><0434><0430> ] TJ 30.0 0.0 Td 129.0 Tz [ <043E><043D> ] TJ 16.6 0.0 Td 114.8 Tz [ <0433><043E><0432><043E><0440><0438><0442><003A> ] TJ 41.0 0.0 Td 129.4 Tz [ <00AB><0421><0435><0440><0434><0446><0435> ] TJ 40.8 0.0 Td 138.0 Tz [ <043C><043E><0435> ] TJ 22.3 0.0 Td 120.0 Tz [ <043E><0431><0440><0430> ] TJ /F0 9 Tf
+-168.2 -10.8 Td 104.9 Tz [ <0442><0438><043B><043E><0441><044C> ] TJ 31.9 0.0 Td 128.0 Tz [ <0432> ] TJ 10.8 0.0 Td 102.9 Tz [ <043A><0430><043C><0435><043D><044C><0021> ] TJ 36.0 0.0 Td 119.1 Tz [ <0423><0434><0430><0440><0438><0432> ] TJ 37.0 0.0 Td 125.3 Tz [ <043F><043E> ] TJ 15.8 0.0 Td 101.3 Tz [ <043D><0435><043C><002C> ] TJ 22.1 0.0 Td 117.3 Tz [ <044F> ] TJ 8.9 0.0 Td 124.8 Tz [ <0443><0448><0438><0431><0443> ] TJ /F0 8 Tf
+-162.5 -10.6 Td 115.5 Tz [ <0441><0435><0431><0435> ] TJ 21.6 0.0 Td 120.0 Tz [ <0440><0443><043A><0443><002E> ] TJ 29.0 0.0 Td 156.0 Tz [ <041D><043E> ] TJ 17.0 0.0 Td 107.2 Tz [ <0432><0441><0435><002D><0442><0430><043A><0438> ] TJ 40.6 0.0 Td 136.0 Tz [ <043C><0438><0440> ] TJ 20.9 0.0 Td 132.0 Tz [ <043D><0435> ] TJ 15.1 0.0 Td 120.0 Tz [ <0432><0438><0434><0430><043B> ] TJ 29.8 0.0 Td 112.0 Tz [ <0441><043E><0437> ] TJ -175.4 -10.6 Td 120.0 Tz [ <0434><0430><043D><044C><044F> ] TJ 30.7 0.0 Td 104.1 Tz [ <043F><0440><0435><043B><0435><0441><0442><043D><0435><0439><0021><002E><002E><00BB> ] TJ 64.1 0.0 Td 204.0 Tz [ <0418> ] TJ 16.6 0.0 Td 122.4 Tz [ <0432><043D><043E><0432><044C> ] TJ 33.1 0.0 Td 156.0 Tz [ <043C><044B> ] TJ 21.8 0.0 Td 126.0 Tz [ <0432><0438><0434><0438><043C> ] TJ /F0 9 Tf
+-164.9 -11.0 Td 106.7 Tz [ <0433><043B><0443><0431><043E><043A><043E><0435> ] TJ 43.9 0.0 Td 104.9 Tz [ <0447><0435><043B><043E><0432><0435><0447><0435><0441><043A><043E><0435> ] TJ 62.4 0.0 Td 99.2 Tz [ <0441><0442><0440><0430><0434><0430><043D><0438><0435><002E> ] TJ 50.9 0.0 Td 112.0 Tz [ <041F><043E><0440><0443><0433><0430> ] TJ
+ET
+endstream
+endobj
+xref
+0 7
+0000000000 65535 f
+0000000015 00000 n
+0000000068 00000 n
+0000000161 00000 n
+0000000287 00000 n
+0000000412 00000 n
+0000000593 00000 n
+trailer<< /Root 1 0 R /Size 7 >>
+startxref
+3428
+%%EOF