Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saxy does parse but does not encode properly #123

Open
StephanMeijer opened this issue Dec 18, 2023 · 1 comment
Open

Saxy does parse but does not encode properly #123

StephanMeijer opened this issue Dec 18, 2023 · 1 comment

Comments

@StephanMeijer
Copy link

When loading in a document using Saxy.SimpleForm.parse_string such as

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<text>&gt;</text>

The result is correctly parsed as:

{"text", [], [">"]}

But when encoding back using Saxy.encode!(simple), result is encoded as:

<text>></text>

So the > character was not properly encoded to &gt;.


Reproduce:

    {:ok, simple} = Saxy.SimpleForm.parse_string("""
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <text>&gt;</text>
    """)

    IO.inspect(simple)

    encoded = Saxy.encode!(simple)

    IO.inspect(encoded)

Output:

{"text", [], [">"]}
"<text>></text>"
@StephanMeijer
Copy link
Author

StephanMeijer commented Dec 18, 2023

While this functions properly, I would like this to either be more well-documented or have behaviours of .parse_string and .encode! be compatible by default:

{:ok, simple} = Saxy.SimpleForm.parse_string("""
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<text>&gt;</text>
""", [expand_entity: :never])

IO.inspect(simple)

encoded = Saxy.encode!(simple)

IO.inspect(encoded)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant