diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2021-12-05 02:17:48 +0100 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2021-12-05 02:52:23 +0100 |
| commit | d65d6edb0e1887871c4de6a4e8a1630927153eae (patch) | |
| tree | 962864b2793913332adfe390521eff747f4c4863 /core/encoding/entity | |
| parent | 3d72e80ccf0f382f03a1c9407c4728862c5bca91 (diff) | |
[xml] Improve XML tests, test `core:encoding/entity`.
Diffstat (limited to 'core/encoding/entity')
| -rw-r--r-- | core/encoding/entity/entity.odin | 7 | ||||
| -rw-r--r-- | core/encoding/entity/example/entity_example.odin | 1 | ||||
| -rw-r--r-- | core/encoding/entity/example/test.html | 2 |
3 files changed, 9 insertions, 1 deletions
diff --git a/core/encoding/entity/entity.odin b/core/encoding/entity/entity.odin index 8742446e6..db1a5ad0b 100644 --- a/core/encoding/entity/entity.odin +++ b/core/encoding/entity/entity.odin @@ -115,7 +115,14 @@ decode_xml :: proc(input: string, options := XML_Decode_Options{}, allocator := We don't need to check if we need to write a `<`, because if it isn't CDATA or a comment, it couldn't have been part of an XML tag body to be decoded here. + + Keep in mind that we could already *be* inside a CDATA tag. + If so, write `>` as a literal and continue. */ + if in_data { + write_rune(&builder, '<') + continue + } in_data = _handle_xml_special(&t, &builder, options) or_return case ']': diff --git a/core/encoding/entity/example/entity_example.odin b/core/encoding/entity/example/entity_example.odin index 161a44827..882203f48 100644 --- a/core/encoding/entity/example/entity_example.odin +++ b/core/encoding/entity/example/entity_example.odin @@ -50,6 +50,7 @@ _main :: proc() { using fmt options := xml.Options{ flags = { .Ignore_Unsupported, .Intern_Comments, .Unbox_CDATA, .Decode_SGML_Entities }} + doc, _ := xml.parse(#load("test.html"), options) defer xml.destroy(doc) diff --git a/core/encoding/entity/example/test.html b/core/encoding/entity/example/test.html index 62a0bb35a..ebbc6470c 100644 --- a/core/encoding/entity/example/test.html +++ b/core/encoding/entity/example/test.html @@ -22,7 +22,7 @@ </div>
<!-- EXPECTED: Foozle]! © BOX ® /BOX42&;1234& -->
<div>
- | | | fj ` \ ® ϱ ∳
+ | | | fj ` \ ® ϱ ∳ ⁏
</div>
</body>
</html>
\ No newline at end of file |