Commit e0775238b8b011755b9682555a8449b8a71f33eb

Authored by Fredrik Fornwall
Committed by Jay Berkenbilt
1 parent d2e7f2a3

Fix QPDFEFStreamObjectHelper::{get,set}Subtype

The /Subtype entry that specifies the mime type of an embedded file is
inside the embedded file stream dictionary directly, not it in the
parameter dictionary.

See Table 45 and 46 in the PDF 1.7 specification:
https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#page=112
examples/qtest/attach-file/output.pdf
No preview for this file type
libqpdf/QPDFEFStreamObjectHelper.cc
... ... @@ -76,7 +76,7 @@ QPDFEFStreamObjectHelper::getSize()
76 76 std::string
77 77 QPDFEFStreamObjectHelper::getSubtype()
78 78 {
79   - auto val = getParam("/Subtype");
  79 + auto val = this->oh.getDict().getKey("/Subtype");
80 80 if (val.isName())
81 81 {
82 82 auto n = val.getName();
... ... @@ -141,7 +141,8 @@ QPDFEFStreamObjectHelper::setModDate(std::string const& date)
141 141 QPDFEFStreamObjectHelper&
142 142 QPDFEFStreamObjectHelper::setSubtype(std::string const& subtype)
143 143 {
144   - setParam("/Subtype", QPDFObjectHandle::newName("/" + subtype));
  144 + this->oh.getDict().replaceKey(
  145 + "/Subtype", QPDFObjectHandle::newName("/" + subtype));
145 146 return *this;
146 147 }
147 148  
... ...
qpdf/qtest/qpdf/add-attachments-1.pdf
... ... @@ -101,8 +101,8 @@ endobj
101 101 /CreationDate (D:20210210091359-05'00')
102 102 /ModDate (D:20210210141359Z)
103 103 /Size 12
104   - /Subtype /text#2fplain
105 104 >>
  105 + /Subtype /text#2fplain
106 106 /Type /EmbeddedFile
107 107 /Length 9 0 R
108 108 >>
... ... @@ -204,20 +204,20 @@ xref
204 204 0000000587 00000 n
205 205 0000000709 00000 n
206 206 0000000904 00000 n
207   -0000001199 00000 n
208   -0000001218 00000 n
209   -0000001488 00000 n
210   -0000001508 00000 n
211   -0000001778 00000 n
212   -0000001821 00000 n
213   -0000001922 00000 n
214   -0000001942 00000 n
215   -0000002061 00000 n
  207 +0000001197 00000 n
  208 +0000001216 00000 n
  209 +0000001486 00000 n
  210 +0000001506 00000 n
  211 +0000001776 00000 n
  212 +0000001819 00000 n
  213 +0000001920 00000 n
  214 +0000001940 00000 n
  215 +0000002059 00000 n
216 216 trailer <<
217 217 /Root 1 0 R
218 218 /Size 18
219 219 /ID [<31415926535897932384626433832795><31415926535897932384626433832795>]
220 220 >>
221 221 startxref
222   -2097
  222 +2095
223 223 %%EOF
... ...
qpdf/qtest/qpdf/copy-attachments-2.pdf
... ... @@ -144,8 +144,8 @@ endobj
144 144 /CreationDate (D:20210210091359-05'00')
145 145 /ModDate (D:20210210141359Z)
146 146 /Size 12
147   - /Subtype /text#2fplain
148 147 >>
  148 + /Subtype /text#2fplain
149 149 /Type /EmbeddedFile
150 150 /Length 12 0 R
151 151 >>
... ... @@ -208,8 +208,8 @@ endobj
208 208 /CreationDate (D:20210210091359-05'00')
209 209 /ModDate (D:20210210141359Z)
210 210 /Size 12
211   - /Subtype /text#2fplain
212 211 >>
  212 + /Subtype /text#2fplain
213 213 /Type /EmbeddedFile
214 214 /Length 18 0 R
215 215 >>
... ... @@ -314,26 +314,26 @@ xref
314 314 0000001039 00000 n
315 315 0000001161 00000 n
316 316 0000001357 00000 n
317   -0000001654 00000 n
318   -0000001674 00000 n
319   -0000001944 00000 n
320   -0000001964 00000 n
321   -0000002234 00000 n
322   -0000002254 00000 n
323   -0000002551 00000 n
324   -0000002571 00000 n
325   -0000002841 00000 n
326   -0000002861 00000 n
327   -0000003131 00000 n
328   -0000003174 00000 n
329   -0000003275 00000 n
330   -0000003295 00000 n
331   -0000003414 00000 n
  317 +0000001652 00000 n
  318 +0000001672 00000 n
  319 +0000001942 00000 n
  320 +0000001962 00000 n
  321 +0000002232 00000 n
  322 +0000002252 00000 n
  323 +0000002547 00000 n
  324 +0000002567 00000 n
  325 +0000002837 00000 n
  326 +0000002857 00000 n
  327 +0000003127 00000 n
  328 +0000003170 00000 n
  329 +0000003271 00000 n
  330 +0000003291 00000 n
  331 +0000003410 00000 n
332 332 trailer <<
333 333 /Root 1 0 R
334 334 /Size 27
335 335 /ID [<31415926535897932384626433832795><31415926535897932384626433832795>]
336 336 >>
337 337 startxref
338   -3450
  338 +3446
339 339 %%EOF
... ...
qpdf/qtest/qpdf/test76.pdf
... ... @@ -108,8 +108,8 @@ endobj
108 108 /CreationDate (D:20210207191121-05'00')
109 109 /ModDate (D:20210208001122Z)
110 110 /Size 9
111   - /Subtype /text#2fplain
112 111 >>
  112 + /Subtype /text#2fplain
113 113 /Type /EmbeddedFile
114 114 /Length 9 0 R
115 115 >>
... ... @@ -129,8 +129,8 @@ endobj
129 129 /Params <<
130 130 /CheckSum <2fce9c8228e360ba9b04a1bd1bf63d6b>
131 131 /Size 11
132   - /Subtype /text#2fplain
133 132 >>
  133 + /Subtype /text#2fplain
134 134 /Type /EmbeddedFile
135 135 /Length 11 0 R
136 136 >>
... ... @@ -150,8 +150,8 @@ endobj
150 150 /Params <<
151 151 /CheckSum <2236c155b1d62b7f00285bba081d4336>
152 152 /Size 11
153   - /Subtype /text#2fplain
154 153 >>
  154 + /Subtype /text#2fplain
155 155 /Type /EmbeddedFile
156 156 /Length 13 0 R
157 157 >>
... ... @@ -214,20 +214,20 @@ xref
214 214 0000000707 00000 n
215 215 0000000876 00000 n
216 216 0000001098 00000 n
217   -0000001389 00000 n
218   -0000001435 00000 n
219   -0000001654 00000 n
220   -0000001702 00000 n
221   -0000001921 00000 n
222   -0000001991 00000 n
223   -0000002092 00000 n
224   -0000002139 00000 n
225   -0000002285 00000 n
  217 +0000001387 00000 n
  218 +0000001433 00000 n
  219 +0000001650 00000 n
  220 +0000001698 00000 n
  221 +0000001915 00000 n
  222 +0000001985 00000 n
  223 +0000002086 00000 n
  224 +0000002133 00000 n
  225 +0000002279 00000 n
226 226 trailer <<
227 227 /Root 1 0 R
228 228 /Size 18
229 229 /ID [<31415926535897932384626433832795><31415926535897932384626433832795>]
230 230 >>
231 231 startxref
232   -2321
  232 +2315
233 233 %%EOF
... ...
qpdf/qtest/qpdf/test77.pdf
... ... @@ -93,8 +93,8 @@ endobj
93 93 /CreationDate (D:20210207191121-05'00')
94 94 /ModDate (D:20210208001122Z)
95 95 /Size 9
96   - /Subtype /text#2fplain
97 96 >>
  97 + /Subtype /text#2fplain
98 98 /Type /EmbeddedFile
99 99 /Length 8 0 R
100 100 >>
... ... @@ -114,8 +114,8 @@ endobj
114 114 /Params <<
115 115 /CheckSum <2236c155b1d62b7f00285bba081d4336>
116 116 /Size 11
117   - /Subtype /text#2fplain
118 117 >>
  118 + /Subtype /text#2fplain
119 119 /Type /EmbeddedFile
120 120 /Length 10 0 R
121 121 >>
... ... @@ -177,18 +177,18 @@ xref
177 177 0000000541 00000 n
178 178 0000000708 00000 n
179 179 0000000930 00000 n
180   -0000001221 00000 n
181   -0000001267 00000 n
182   -0000001485 00000 n
183   -0000001556 00000 n
184   -0000001657 00000 n
185   -0000001705 00000 n
186   -0000001852 00000 n
  180 +0000001219 00000 n
  181 +0000001265 00000 n
  182 +0000001481 00000 n
  183 +0000001552 00000 n
  184 +0000001653 00000 n
  185 +0000001701 00000 n
  186 +0000001848 00000 n
187 187 trailer <<
188 188 /Root 1 0 R
189 189 /Size 15
190 190 /ID [<31415926535897932384626433832795><31415926535897932384626433832795>]
191 191 >>
192 192 startxref
193   -1888
  193 +1884
194 194 %%EOF
... ...