Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
koa-xml-parser
Advanced tools
Readme
$ yarn add koa-xml-parser
const Koa = require('koa');
const xmlParser = require('koa-xml-parser');
// Configuration object can be omitted, in this case default properties are used
const parseXML = xmlParser({
limit: '1MB', // Reject payloads larger than 1 MB
encoding: 'UTF-8', // Explicitly set UTF-8 encoding
xml: {
normalize: true, // Trim whitespace inside text nodes
normalizeTags: true, // Transform tags to lowercase
explicitArray: false // Only put nodes in array if >1
}
});
const app = new Koa();
app.use(parseXML);
This will parse any XML-based request and place it as an object on context.req.body
and
context.request.body
the same way most body parsers do.
An XML-based request is determined by the value of the Content-Type
header. By default, any
Content-Type
header ending in /xml
or +xml
is assumed to be XML and is parsed. For
example, the following headers will all match:
text/xml
application/xml
application/rss+xml
If you need to match against a custom Content-Type
, you can pass in the type
property to a
configuration object.
As shown above, instead of relying on library defaults, you can pass custom configuration
options to the parser building function. config
object has the following parameters:
type
- either a string or an array of strings representing content type(s) indicating
that body should be parsed. Types must conform to a format of
type-is library.encoding
- a string representing explicit request encoding. UTF-8
by default.limit
- a number or a string representing the request size limit. 1mb
by default.xml
- an object containing configuration object for
xml2js library that is used to parse XML
internally. You can refer to the library's
documentation
for a full list of options with their corresponding possible values.$ yarn test
FAQs
Simple XML parsing middleware for Koa 2.x
The npm package koa-xml-parser receives a total of 75 weekly downloads. As such, koa-xml-parser popularity was classified as not popular.
We found that koa-xml-parser demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.