<html>
<head>
<base href="https://bugzilla.netfilter.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - invalid json generated by ipset list -output json"
href="https://bugzilla.netfilter.org/show_bug.cgi?id=1726#c1">Comment # 1</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - invalid json generated by ipset list -output json"
href="https://bugzilla.netfilter.org/show_bug.cgi?id=1726">bug 1726</a>
from <span class="vcard"><a class="email" href="mailto:mark@glines.org" title="mark@glines.org">mark@glines.org</a>
</span></b>
<pre>Created <span class=""><a href="attachment.cgi?id=732" name="attach_732" title="Fix ipset list -output json -name">attachment 732</a> <a href="attachment.cgi?id=732&action=edit" title="Fix ipset list -output json -name">[details]</a></span>
Fix ipset list -output json -name
This fixes -output json -name.
Adds curly braces. Adds a static flag to keep track of whether a comma is
necessary. This is very similar to how list_create() handles it, in the
non-"-name" case.
Output before:
---
% sudo src/ipset list -output json -name
[
"name" : "blocklist.de.ipv4"
"name" : "blocklist.de.ipv6"
]
---
Output after:
---
sudo src/ipset list -output json -name
[
{ "name" : "blocklist.de.ipv4" },
{ "name" : "blocklist.de.ipv6" }
]
---
While testing this, I added an "else" to solve a logic problem. It wants to do
one thing for xml, another thing for json, and a third thing for plain text.
But because of the missing "else", xml output contains both xml and plaintext.
Like this:
---
% sudo src/ipset list -output xml -name
<ipsets>
<ipset name="blocklist.de.ipv4"/>
blocklist.de.ipv4
<ipset name="blocklist.de.ipv6"/>
blocklist.de.ipv6
</ipsets>
---
The added "else" resolves that.
---
% sudo src/ipset list -output xml -name
<ipsets>
<ipset name="blocklist.de.ipv4"/>
<ipset name="blocklist.de.ipv6"/>
</ipsets>
---</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are watching all bug changes.</li>
</ul>
</body>
</html>