diff options
author | Ryan Harrison <rharrison@chromium.org> | 2018-08-22 20:50:14 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-08-22 20:50:14 +0000 |
commit | 15f1a88dece664ae7300d9a60fe124cec1f2b9de (patch) | |
tree | a13d363deadc618c919ba6cbf2b7982511a7db7c /fpdfsdk | |
parent | 7e7e0b8379c4bdcf3e16cd2298afe49f03fefdfb (diff) | |
download | pdfium-15f1a88dece664ae7300d9a60fe124cec1f2b9de.tar.xz |
Properly handle language markers in decoded text
In text like document title 0x001B is used as a marker for the
beginning/end of a language metadata section. Currently PDFium does
nothing with this data, but when returning the 'decoded' text it needs
to be stripped out.
The existing code assumed that the two bytes following a marker would
be the data to be removed and did nothing to track if it was in/out of
one of these regions. This led to a situation where it would always
strip the two bytes following the region, since it assumed the end
marker was the beginning of a new region.
This CL corrects the detection and handling of these regions, and adds
a regression test for the reported bug.
BUG=pdfium:182
Change-Id: I92ddba5666274a8986fed03f502a0331f150f7ac
Reviewed-on: https://pdfium-review.googlesource.com/41070
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/fpdf_doc_embeddertest.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/fpdfsdk/fpdf_doc_embeddertest.cpp b/fpdfsdk/fpdf_doc_embeddertest.cpp index a9eb4b8cb7..5c0223ee46 100644 --- a/fpdfsdk/fpdf_doc_embeddertest.cpp +++ b/fpdfsdk/fpdf_doc_embeddertest.cpp @@ -358,6 +358,17 @@ TEST_F(FPDFDocEmbeddertest, GetMetaText) { WideString::FromUTF16LE(buf, FXSYS_len(kExpectedModDate))); } +TEST_F(FPDFDocEmbeddertest, Bug_182) { + ASSERT_TRUE(OpenDocument("bug_182.pdf")); + + unsigned short buf[128]; + constexpr wchar_t kExpectedTitle[] = L"Super Visual Formade 印刷"; + + ASSERT_EQ(48u, FPDF_GetMetaText(document(), "Title", buf, sizeof(buf))); + EXPECT_EQ(WideString(kExpectedTitle), + WideString::FromUTF16LE(buf, FXSYS_len(kExpectedTitle))); +} + TEST_F(FPDFDocEmbeddertest, GetMetaTextSameObjectNumber) { ASSERT_TRUE(OpenDocument("annotation_highlight_square_with_ap.pdf")); |