OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "xfa/fde/xml/fde_xml_imp.h" | 5 #include "xfa/fde/xml/fde_xml_imp.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "xfa/fgas/crt/fgas_stream.h" | 10 #include "xfa/fgas/crt/fgas_stream.h" |
11 | 11 |
12 TEST(CFDE_XMLSyntaxParser, CData) { | 12 TEST(CFDE_XMLSyntaxParser, CData) { |
13 const FX_WCHAR* input = | 13 const FX_WCHAR* input = |
14 L"<script contentType=\"application/x-javascript\">\n" | 14 L"<script contentType=\"application/x-javascript\">\n" |
15 L" <![CDATA[\n" | 15 L" <![CDATA[\n" |
16 L" if (a[1] < 3)\n" | 16 L" if (a[1] < 3)\n" |
17 L" app.alert(\"Tclams\");\n" | 17 L" app.alert(\"Tclams\");\n" |
18 L" ]]>\n" | 18 L" ]]>\n" |
19 L"</script>"; | 19 L"</script>"; |
20 | 20 |
21 const FX_WCHAR* cdata = | 21 const FX_WCHAR* cdata = |
22 L"\n" | 22 L"\n" |
23 L" if (a[1] < 3)\n" | 23 L" if (a[1] < 3)\n" |
24 L" app.alert(\"Tclams\");\n" | 24 L" app.alert(\"Tclams\");\n" |
25 L" "; | 25 L" "; |
26 | 26 |
27 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. | 27 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. |
28 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); | 28 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); |
29 std::unique_ptr<IFX_Stream> stream(IFX_Stream::CreateStream( | 29 std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( |
30 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); | 30 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); |
31 CFDE_XMLSyntaxParser parser; | 31 CFDE_XMLSyntaxParser parser; |
32 parser.Init(stream.get(), 256); | 32 parser.Init(stream.get(), 256); |
33 | 33 |
34 CFX_WideString data; | 34 CFX_WideString data; |
35 | 35 |
36 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); | 36 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); |
37 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); | 37 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); |
38 parser.GetTagName(data); | 38 parser.GetTagName(data); |
39 EXPECT_EQ(L"script", data); | 39 EXPECT_EQ(L"script", data); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 const FX_WCHAR* cdata = | 78 const FX_WCHAR* cdata = |
79 L"\n" | 79 L"\n" |
80 L" if (a[1] < 3)\n" | 80 L" if (a[1] < 3)\n" |
81 L" app.alert(\"Tclams\");\n" | 81 L" app.alert(\"Tclams\");\n" |
82 L" </script>\n" | 82 L" </script>\n" |
83 L" "; | 83 L" "; |
84 | 84 |
85 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. | 85 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. |
86 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); | 86 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); |
87 std::unique_ptr<IFX_Stream> stream(IFX_Stream::CreateStream( | 87 std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( |
88 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); | 88 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); |
89 CFDE_XMLSyntaxParser parser; | 89 CFDE_XMLSyntaxParser parser; |
90 parser.Init(stream.get(), 256); | 90 parser.Init(stream.get(), 256); |
91 | 91 |
92 CFX_WideString data; | 92 CFX_WideString data; |
93 | 93 |
94 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); | 94 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); |
95 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); | 95 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); |
96 parser.GetTagName(data); | 96 parser.GetTagName(data); |
97 EXPECT_EQ(L"script", data); | 97 EXPECT_EQ(L"script", data); |
(...skipping 26 matching lines...) Expand all Loading... |
124 } | 124 } |
125 | 125 |
126 TEST(CFDE_XMLSyntaxParser, ArrowBangArrow) { | 126 TEST(CFDE_XMLSyntaxParser, ArrowBangArrow) { |
127 const FX_WCHAR* input = | 127 const FX_WCHAR* input = |
128 L"<script contentType=\"application/x-javascript\">\n" | 128 L"<script contentType=\"application/x-javascript\">\n" |
129 L" <!>\n" | 129 L" <!>\n" |
130 L"</script>"; | 130 L"</script>"; |
131 | 131 |
132 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. | 132 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. |
133 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); | 133 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); |
134 std::unique_ptr<IFX_Stream> stream(IFX_Stream::CreateStream( | 134 std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( |
135 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); | 135 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); |
136 CFDE_XMLSyntaxParser parser; | 136 CFDE_XMLSyntaxParser parser; |
137 parser.Init(stream.get(), 256); | 137 parser.Init(stream.get(), 256); |
138 | 138 |
139 CFX_WideString data; | 139 CFX_WideString data; |
140 | 140 |
141 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); | 141 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); |
142 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); | 142 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); |
143 parser.GetTagName(data); | 143 parser.GetTagName(data); |
144 EXPECT_EQ(L"script", data); | 144 EXPECT_EQ(L"script", data); |
(...skipping 22 matching lines...) Expand all Loading... |
167 } | 167 } |
168 | 168 |
169 TEST(CFDE_XMLSyntaxParser, ArrowBangBracketArrow) { | 169 TEST(CFDE_XMLSyntaxParser, ArrowBangBracketArrow) { |
170 const FX_WCHAR* input = | 170 const FX_WCHAR* input = |
171 L"<script contentType=\"application/x-javascript\">\n" | 171 L"<script contentType=\"application/x-javascript\">\n" |
172 L" <![>\n" | 172 L" <![>\n" |
173 L"</script>"; | 173 L"</script>"; |
174 | 174 |
175 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. | 175 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. |
176 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); | 176 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); |
177 std::unique_ptr<IFX_Stream> stream(IFX_Stream::CreateStream( | 177 std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( |
178 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); | 178 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); |
179 CFDE_XMLSyntaxParser parser; | 179 CFDE_XMLSyntaxParser parser; |
180 parser.Init(stream.get(), 256); | 180 parser.Init(stream.get(), 256); |
181 | 181 |
182 CFX_WideString data; | 182 CFX_WideString data; |
183 | 183 |
184 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); | 184 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); |
185 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); | 185 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); |
186 parser.GetTagName(data); | 186 parser.GetTagName(data); |
187 EXPECT_EQ(L"script", data); | 187 EXPECT_EQ(L"script", data); |
(...skipping 16 matching lines...) Expand all Loading... |
204 } | 204 } |
205 | 205 |
206 TEST(CFDE_XMLSyntaxParser, IncompleteCData) { | 206 TEST(CFDE_XMLSyntaxParser, IncompleteCData) { |
207 const FX_WCHAR* input = | 207 const FX_WCHAR* input = |
208 L"<script contentType=\"application/x-javascript\">\n" | 208 L"<script contentType=\"application/x-javascript\">\n" |
209 L" <![CDATA>\n" | 209 L" <![CDATA>\n" |
210 L"</script>"; | 210 L"</script>"; |
211 | 211 |
212 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. | 212 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. |
213 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); | 213 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); |
214 std::unique_ptr<IFX_Stream> stream(IFX_Stream::CreateStream( | 214 std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( |
215 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); | 215 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); |
216 CFDE_XMLSyntaxParser parser; | 216 CFDE_XMLSyntaxParser parser; |
217 parser.Init(stream.get(), 256); | 217 parser.Init(stream.get(), 256); |
218 | 218 |
219 CFX_WideString data; | 219 CFX_WideString data; |
220 | 220 |
221 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); | 221 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); |
222 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); | 222 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); |
223 parser.GetTagName(data); | 223 parser.GetTagName(data); |
224 EXPECT_EQ(L"script", data); | 224 EXPECT_EQ(L"script", data); |
(...skipping 16 matching lines...) Expand all Loading... |
241 } | 241 } |
242 | 242 |
243 TEST(CFDE_XMLSyntaxParser, UnClosedCData) { | 243 TEST(CFDE_XMLSyntaxParser, UnClosedCData) { |
244 const FX_WCHAR* input = | 244 const FX_WCHAR* input = |
245 L"<script contentType=\"application/x-javascript\">\n" | 245 L"<script contentType=\"application/x-javascript\">\n" |
246 L" <![CDATA[\n" | 246 L" <![CDATA[\n" |
247 L"</script>"; | 247 L"</script>"; |
248 | 248 |
249 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. | 249 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. |
250 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); | 250 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); |
251 std::unique_ptr<IFX_Stream> stream(IFX_Stream::CreateStream( | 251 std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( |
252 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); | 252 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); |
253 CFDE_XMLSyntaxParser parser; | 253 CFDE_XMLSyntaxParser parser; |
254 parser.Init(stream.get(), 256); | 254 parser.Init(stream.get(), 256); |
255 | 255 |
256 CFX_WideString data; | 256 CFX_WideString data; |
257 | 257 |
258 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); | 258 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); |
259 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); | 259 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); |
260 parser.GetTagName(data); | 260 parser.GetTagName(data); |
261 EXPECT_EQ(L"script", data); | 261 EXPECT_EQ(L"script", data); |
(...skipping 16 matching lines...) Expand all Loading... |
278 } | 278 } |
279 | 279 |
280 TEST(CFDE_XMLSyntaxParser, EmptyCData) { | 280 TEST(CFDE_XMLSyntaxParser, EmptyCData) { |
281 const FX_WCHAR* input = | 281 const FX_WCHAR* input = |
282 L"<script contentType=\"application/x-javascript\">\n" | 282 L"<script contentType=\"application/x-javascript\">\n" |
283 L" <![CDATA[]]>\n" | 283 L" <![CDATA[]]>\n" |
284 L"</script>"; | 284 L"</script>"; |
285 | 285 |
286 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. | 286 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. |
287 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); | 287 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); |
288 std::unique_ptr<IFX_Stream> stream(IFX_Stream::CreateStream( | 288 std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( |
289 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); | 289 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); |
290 CFDE_XMLSyntaxParser parser; | 290 CFDE_XMLSyntaxParser parser; |
291 parser.Init(stream.get(), 256); | 291 parser.Init(stream.get(), 256); |
292 | 292 |
293 CFX_WideString data; | 293 CFX_WideString data; |
294 | 294 |
295 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); | 295 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); |
296 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); | 296 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); |
297 parser.GetTagName(data); | 297 parser.GetTagName(data); |
298 EXPECT_EQ(L"script", data); | 298 EXPECT_EQ(L"script", data); |
(...skipping 26 matching lines...) Expand all Loading... |
325 } | 325 } |
326 | 326 |
327 TEST(CFDE_XMLSyntaxParser, Comment) { | 327 TEST(CFDE_XMLSyntaxParser, Comment) { |
328 const FX_WCHAR* input = | 328 const FX_WCHAR* input = |
329 L"<script contentType=\"application/x-javascript\">\n" | 329 L"<script contentType=\"application/x-javascript\">\n" |
330 L" <!-- A Comment -->\n" | 330 L" <!-- A Comment -->\n" |
331 L"</script>"; | 331 L"</script>"; |
332 | 332 |
333 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. | 333 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. |
334 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); | 334 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); |
335 std::unique_ptr<IFX_Stream> stream(IFX_Stream::CreateStream( | 335 std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( |
336 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); | 336 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); |
337 CFDE_XMLSyntaxParser parser; | 337 CFDE_XMLSyntaxParser parser; |
338 parser.Init(stream.get(), 256); | 338 parser.Init(stream.get(), 256); |
339 | 339 |
340 CFX_WideString data; | 340 CFX_WideString data; |
341 | 341 |
342 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); | 342 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); |
343 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); | 343 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); |
344 parser.GetTagName(data); | 344 parser.GetTagName(data); |
345 EXPECT_EQ(L"script", data); | 345 EXPECT_EQ(L"script", data); |
(...skipping 22 matching lines...) Expand all Loading... |
368 } | 368 } |
369 | 369 |
370 TEST(CFDE_XMLSyntaxParser, IncorrectCommentStart) { | 370 TEST(CFDE_XMLSyntaxParser, IncorrectCommentStart) { |
371 const FX_WCHAR* input = | 371 const FX_WCHAR* input = |
372 L"<script contentType=\"application/x-javascript\">\n" | 372 L"<script contentType=\"application/x-javascript\">\n" |
373 L" <!- A Comment -->\n" | 373 L" <!- A Comment -->\n" |
374 L"</script>"; | 374 L"</script>"; |
375 | 375 |
376 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. | 376 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. |
377 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); | 377 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); |
378 std::unique_ptr<IFX_Stream> stream(IFX_Stream::CreateStream( | 378 std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( |
379 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); | 379 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); |
380 CFDE_XMLSyntaxParser parser; | 380 CFDE_XMLSyntaxParser parser; |
381 parser.Init(stream.get(), 256); | 381 parser.Init(stream.get(), 256); |
382 | 382 |
383 CFX_WideString data; | 383 CFX_WideString data; |
384 | 384 |
385 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); | 385 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); |
386 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); | 386 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); |
387 parser.GetTagName(data); | 387 parser.GetTagName(data); |
388 EXPECT_EQ(L"script", data); | 388 EXPECT_EQ(L"script", data); |
(...skipping 22 matching lines...) Expand all Loading... |
411 } | 411 } |
412 | 412 |
413 TEST(CFDE_XMLSyntaxParser, CommentEmpty) { | 413 TEST(CFDE_XMLSyntaxParser, CommentEmpty) { |
414 const FX_WCHAR* input = | 414 const FX_WCHAR* input = |
415 L"<script contentType=\"application/x-javascript\">\n" | 415 L"<script contentType=\"application/x-javascript\">\n" |
416 L" <!---->\n" | 416 L" <!---->\n" |
417 L"</script>"; | 417 L"</script>"; |
418 | 418 |
419 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. | 419 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. |
420 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); | 420 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); |
421 std::unique_ptr<IFX_Stream> stream(IFX_Stream::CreateStream( | 421 std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( |
422 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); | 422 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); |
423 CFDE_XMLSyntaxParser parser; | 423 CFDE_XMLSyntaxParser parser; |
424 parser.Init(stream.get(), 256); | 424 parser.Init(stream.get(), 256); |
425 | 425 |
426 CFX_WideString data; | 426 CFX_WideString data; |
427 | 427 |
428 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); | 428 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); |
429 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); | 429 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); |
430 parser.GetTagName(data); | 430 parser.GetTagName(data); |
431 EXPECT_EQ(L"script", data); | 431 EXPECT_EQ(L"script", data); |
(...skipping 22 matching lines...) Expand all Loading... |
454 } | 454 } |
455 | 455 |
456 TEST(CFDE_XMLSyntaxParser, CommentThreeDash) { | 456 TEST(CFDE_XMLSyntaxParser, CommentThreeDash) { |
457 const FX_WCHAR* input = | 457 const FX_WCHAR* input = |
458 L"<script contentType=\"application/x-javascript\">\n" | 458 L"<script contentType=\"application/x-javascript\">\n" |
459 L" <!--->\n" | 459 L" <!--->\n" |
460 L"</script>"; | 460 L"</script>"; |
461 | 461 |
462 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. | 462 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. |
463 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); | 463 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); |
464 std::unique_ptr<IFX_Stream> stream(IFX_Stream::CreateStream( | 464 std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( |
465 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); | 465 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); |
466 CFDE_XMLSyntaxParser parser; | 466 CFDE_XMLSyntaxParser parser; |
467 parser.Init(stream.get(), 256); | 467 parser.Init(stream.get(), 256); |
468 | 468 |
469 CFX_WideString data; | 469 CFX_WideString data; |
470 | 470 |
471 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); | 471 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); |
472 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); | 472 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); |
473 parser.GetTagName(data); | 473 parser.GetTagName(data); |
474 EXPECT_EQ(L"script", data); | 474 EXPECT_EQ(L"script", data); |
(...skipping 14 matching lines...) Expand all Loading... |
489 } | 489 } |
490 | 490 |
491 TEST(CFDE_XMLSyntaxParser, CommentTwoDash) { | 491 TEST(CFDE_XMLSyntaxParser, CommentTwoDash) { |
492 const FX_WCHAR* input = | 492 const FX_WCHAR* input = |
493 L"<script contentType=\"application/x-javascript\">\n" | 493 L"<script contentType=\"application/x-javascript\">\n" |
494 L" <!-->\n" | 494 L" <!-->\n" |
495 L"</script>"; | 495 L"</script>"; |
496 | 496 |
497 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. | 497 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. |
498 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); | 498 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); |
499 std::unique_ptr<IFX_Stream> stream(IFX_Stream::CreateStream( | 499 std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( |
500 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); | 500 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); |
501 CFDE_XMLSyntaxParser parser; | 501 CFDE_XMLSyntaxParser parser; |
502 parser.Init(stream.get(), 256); | 502 parser.Init(stream.get(), 256); |
503 | 503 |
504 CFX_WideString data; | 504 CFX_WideString data; |
505 | 505 |
506 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); | 506 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); |
507 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); | 507 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); |
508 parser.GetTagName(data); | 508 parser.GetTagName(data); |
509 EXPECT_EQ(L"script", data); | 509 EXPECT_EQ(L"script", data); |
(...skipping 18 matching lines...) Expand all Loading... |
528 L"<script contentType=\"application/x-javascript\">" | 528 L"<script contentType=\"application/x-javascript\">" |
529 L"B" | 529 L"B" |
530 L"T" | 530 L"T" |
531 L"H" | 531 L"H" |
532 L"ꭈ" | 532 L"ꭈ" |
533 L"�" | 533 L"�" |
534 L"</script>"; | 534 L"</script>"; |
535 | 535 |
536 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. | 536 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. |
537 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); | 537 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); |
538 std::unique_ptr<IFX_Stream> stream(IFX_Stream::CreateStream( | 538 std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( |
539 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); | 539 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); |
540 CFDE_XMLSyntaxParser parser; | 540 CFDE_XMLSyntaxParser parser; |
541 parser.Init(stream.get(), 256); | 541 parser.Init(stream.get(), 256); |
542 | 542 |
543 CFX_WideString data; | 543 CFX_WideString data; |
544 | 544 |
545 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); | 545 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); |
546 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); | 546 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); |
547 parser.GetTagName(data); | 547 parser.GetTagName(data); |
548 EXPECT_EQ(L"script", data); | 548 EXPECT_EQ(L"script", data); |
(...skipping 19 matching lines...) Expand all Loading... |
568 | 568 |
569 TEST(CFDE_XMLSyntaxParser, EntityOverflowHex) { | 569 TEST(CFDE_XMLSyntaxParser, EntityOverflowHex) { |
570 const FX_WCHAR* input = | 570 const FX_WCHAR* input = |
571 L"<script contentType=\"application/x-javascript\">" | 571 L"<script contentType=\"application/x-javascript\">" |
572 L"�" | 572 L"�" |
573 L"�" | 573 L"�" |
574 L"</script>"; | 574 L"</script>"; |
575 | 575 |
576 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. | 576 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. |
577 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); | 577 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); |
578 std::unique_ptr<IFX_Stream> stream(IFX_Stream::CreateStream( | 578 std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( |
579 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); | 579 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); |
580 CFDE_XMLSyntaxParser parser; | 580 CFDE_XMLSyntaxParser parser; |
581 parser.Init(stream.get(), 256); | 581 parser.Init(stream.get(), 256); |
582 | 582 |
583 CFX_WideString data; | 583 CFX_WideString data; |
584 | 584 |
585 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); | 585 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); |
586 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); | 586 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); |
587 parser.GetTagName(data); | 587 parser.GetTagName(data); |
588 EXPECT_EQ(L"script", data); | 588 EXPECT_EQ(L"script", data); |
(...skipping 19 matching lines...) Expand all Loading... |
608 | 608 |
609 TEST(CFDE_XMLSyntaxParser, EntityOverflowDecimal) { | 609 TEST(CFDE_XMLSyntaxParser, EntityOverflowDecimal) { |
610 const FX_WCHAR* input = | 610 const FX_WCHAR* input = |
611 L"<script contentType=\"application/x-javascript\">" | 611 L"<script contentType=\"application/x-javascript\">" |
612 L"�" | 612 L"�" |
613 L"�" | 613 L"�" |
614 L"</script>"; | 614 L"</script>"; |
615 | 615 |
616 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. | 616 // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. |
617 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); | 617 size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); |
618 std::unique_ptr<IFX_Stream> stream(IFX_Stream::CreateStream( | 618 std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream( |
619 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); | 619 reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0)); |
620 CFDE_XMLSyntaxParser parser; | 620 CFDE_XMLSyntaxParser parser; |
621 parser.Init(stream.get(), 256); | 621 parser.Init(stream.get(), 256); |
622 | 622 |
623 CFX_WideString data; | 623 CFX_WideString data; |
624 | 624 |
625 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); | 625 EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); |
626 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); | 626 EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse()); |
627 parser.GetTagName(data); | 627 parser.GetTagName(data); |
628 EXPECT_EQ(L"script", data); | 628 EXPECT_EQ(L"script", data); |
629 | 629 |
630 EXPECT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse()); | 630 EXPECT_EQ(FDE_XmlSyntaxResult::AttriName, parser.DoSyntaxParse()); |
631 parser.GetAttributeName(data); | 631 parser.GetAttributeName(data); |
632 EXPECT_EQ(L"contentType", data); | 632 EXPECT_EQ(L"contentType", data); |
633 EXPECT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse()); | 633 EXPECT_EQ(FDE_XmlSyntaxResult::AttriValue, parser.DoSyntaxParse()); |
634 parser.GetAttributeValue(data); | 634 parser.GetAttributeValue(data); |
635 EXPECT_EQ(L"application/x-javascript", data); | 635 EXPECT_EQ(L"application/x-javascript", data); |
636 | 636 |
637 EXPECT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse()); | 637 EXPECT_EQ(FDE_XmlSyntaxResult::ElementBreak, parser.DoSyntaxParse()); |
638 EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); | 638 EXPECT_EQ(FDE_XmlSyntaxResult::Text, parser.DoSyntaxParse()); |
639 parser.GetTextData(data); | 639 parser.GetTextData(data); |
640 EXPECT_EQ(L" ", data); | 640 EXPECT_EQ(L" ", data); |
641 | 641 |
642 EXPECT_EQ(FDE_XmlSyntaxResult::ElementClose, parser.DoSyntaxParse()); | 642 EXPECT_EQ(FDE_XmlSyntaxResult::ElementClose, parser.DoSyntaxParse()); |
643 parser.GetTagName(data); | 643 parser.GetTagName(data); |
644 EXPECT_EQ(L"script", data); | 644 EXPECT_EQ(L"script", data); |
645 | 645 |
646 EXPECT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse()); | 646 EXPECT_EQ(FDE_XmlSyntaxResult::EndOfString, parser.DoSyntaxParse()); |
647 } | 647 } |
OLD | NEW |