
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Tasty multipart form data parser built with cython.
pip install multifruits
multifruits
has one Parser
class and two helpers: extract_filename
and
parse_content_disposition
.
Parser
Parser
needs the Content-Type
header value and a handler, which could
define one or more of these methods:
on_body_begin()
on_part_begin()
on_header(name: bytes, value: bytes)
on_headers_complete()
on_data(data: bytes)
on_part_complete()
on_body_complete()
Example:
from multifruits import Parser
class MyHandler:
def on_part_begin(self):
self.part = MyPart()
def on_header(self, name, value):
self.part.headers[name] = value
def on_data(self, data):
self.part.write(data)
handler = MyHandler()
parser = Parser(handler, request.headers['Content-Type'])
parser.feed_data(request.body) # You can pass chunks
parse_content_disposition
Takes raw Content-Disposition
header value and returns the disposition type
(attachment
, form-data
, inline
and so on) and the parameters parsed as a
dictionary.
Example:
dtype, params = parse_content_disposition(b'inline; filename="foo.html"')
assert dtype == b'inline'
assert params == {b'filename': b'foo.html'}
extract_filename
Takes parameters from parse_content_disposition
as a dict and tries to
return the appropriated str
filename (like filename*
).
Example:
assert extract_filename({
b'filename*': "UTF-8''foo-ä-€.html".encode()
}) == 'foo-ä-€.html'
You need a virtualenv with cython installed, then:
git clone https://github.com/pyrates/multifruits
cd multifruits
make compile
python setup.py develop
To run tests:
make test
FAQs
Tasty multipart form data parser built with cython.
We found that multifruits demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.