
Research
/Security News
Malicious npm Packages Target WhatsApp Developers with Remote Kill Switch
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Sloppy XML is a single-file XML parser library that prioritizes resilience over strict XML compliance. In fact it tries not to be XML compliant at all. It's specifically designed to handle malformed XML commonly generated by LLMs, automated systems, and other sources where perfect XML structure cannot be guaranteed.
The parser provides both streaming and tree-building capabilities with robust error recovery mechanisms, making it ideal for parsing XML from unreliable sources while maintaining reasonable performance.
Note: this library was 100% AI generated with Claude Code and used experimentally for some evals I'm doing. I will try to fix it up as good as possible as I ran into issues, but I cannot vouch for the quality of it.
import sloppy_xml
# Streaming API - handle malformed XML gracefully
xml_content = '''
<root>
<item name="test" broken-attr=>
Some text with <unclosed-tag>
<!-- Malformed comment --
</item>
</root>
'''
# Stream parsing with error recovery
for event in sloppy_xml.stream_parse(xml_content):
if isinstance(event, sloppy_xml.StartElement):
print(f"Start: {event.name}, attrs: {event.attrs}")
elif isinstance(event, sloppy_xml.EndElement):
print(f"End: {event.name}")
elif isinstance(event, sloppy_xml.Text):
print(f"Text: {repr(event.content)}")
elif isinstance(event, sloppy_xml.ParseError):
print(f"Error recovered: {event.message} at {event.line}:{event.column}")
# Tree parsing - get an ElementTree despite malformed input
root = sloppy_xml.tree_parse(xml_content)
print(f"Parsed tree with root: {root.tag}")
The streaming parser emits these event types:
StartElement
- Opening tags with attributes and position infoEndElement
- Closing tags (including auto-closed mismatched tags)Text
- Text content with CDATA detectionComment
- XML commentsProcessingInstruction
- Processing instructions like <?xml?>
EntityRef
- Entity references with automatic resolutionParseError
- Recoverable parsing errors with diagnostic informationsloppy_xml.stream_parse(xml_input)
Returns an iterator of events for streaming XML processing.
sloppy_xml.tree_parse(xml_input)
Returns an xml.etree.ElementTree.Element
root node.
uv add sloppy-xml-py
This project uses uv for dependency management:
# Setup
uv sync
# Run tests
uv run pytest
# Format code
uv run ruff format
# Check code quality
uv run ruff check
# Build package
uv build
Sloppy XML fills the gap for applications that need structured XML parsing with aggressive error recovery, particularly for machine-generated content.
If you like the project and find it useful you can become a sponsor.
FAQs
A sloppy XML parser for Python designed to be used with LLMs
We found that sloppy-xml demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.