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

Fix XML escape in JUnit formatter #62

Merged
merged 1 commit into from
May 16, 2016

Conversation

seikichi
Copy link
Contributor

The JUnit formatter does not escape special characters correctly.
For example, consider the following (broken) lua program foo.lua.

local foo =

When I run luacheck with --formatter=JUnit option,

% luacheck --formatter=JUnit foo.lua
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="Luacheck report" tests="1">
    <testcase name="foo.lua:1" classname="foo.lua">
        <failure type="E011" message="foo.lua:2:1: expected expression near <eof>"/>
    </testcase>
</testsuite>

The above result is an invalid XML, the xmllint command reports following errors.

% xmllint <(luacheck --formatter=JUnit foo.lua)
/dev/fd/11:4: parser error : Unescaped '<' not allowed in attributes values
        <failure type="E011" message="foo.lua:2:1: expected expression near <eof
...

This commit fixes the following escaping problem.

The JUnit formatter does not escape special characters correctly.
For example, consider the following (broken) lua program `foo.lua`.

```lua
local foo =
```

When I run `luacheck` with `--formatter=JUnit` options,

```bash
% luacheck --formatter=JUnit foo.lua
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="Luacheck report" tests="1">
    <testcase name="foo.lua:1" classname="foo.lua">
        <failure type="E011" message="foo.lua:2:1: expected expression near <eof>"/>
    </testcase>
</testsuite>
```

The above result is an invalid XML, the `xmllint` command reports following errors.

```bash
% xmllint <(luacheck --formatter=JUnit foo.lua)
/dev/fd/11:4: parser error : Unescaped '<' not allowed in attributes values
        <failure type="E011" message="foo.lua:2:1: expected expression near <eof
...
```

This commit fixes the following escaping problem.
@mpeterv
Copy link
Owner

mpeterv commented May 16, 2016

Thank you! I'll release a bugfix version this week.

@mpeterv mpeterv merged commit 1da41b7 into mpeterv:master May 16, 2016
@mpeterv
Copy link
Owner

mpeterv commented Jun 9, 2016

0.15.1 released, sorry for the delay 😞

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

Successfully merging this pull request may close these issues.

None yet

2 participants