miximka / mimeparser Goto Github PK
View Code? Open in Web Editor NEWMime parsing in Swift | Relevant RFCs: RFC 822, RFC 2045, RFC 2046
License: MIT License
Mime parsing in Swift | Relevant RFCs: RFC 822, RFC 2045, RFC 2046
License: MIT License
Parsing the attached NNTP message with MimeParser fails to include the "Subject" header, because it is preceded by a "Cc" header with no content:
Cc:
Subject: Emacs implementations, list of, regular post [long, FAQ]
The problem is the regular expression used to parse the headers in RFC822HeaderFieldsPartitioner.fields()
:
let regex = try! NSRegularExpression(pattern: "(.+?):\\s*(.+)", options: [])
It would probably be better to parse these 1 line at a time.
In the odd event that an attachment has content-type like this:
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
This may be an odd combination, but it is definitely out there in the wild and should be handled even if it is "non-standard"
The library tries to decode it as ".ascii" here:
Even though the content-transfer-encoding is specified as 7bit, the data is actually utf-8 and standard ascii decoding will fail.
The charset should possibly override the transfer encoding, or possibly the decoder could fall-back to trying .utf8 if the .ascii decode fails. For example:
guard let decoded = raw.data(using: .ascii) else {
raw.data(using: .utf8) else { throw Error.decodingFailed }
}
Great parser! But header names are not case sensitive, so looking for "Content-Type" in HeaderParser.parse is a bit too strict.
First of all thank you for this library. I've used it to retrieve some headers, and I stumbled upon a header that contained UTF-8 data, is there a way to decode this header using this library ?
Format seems to be ?=encoding?charset?mytexthere?=
Thank you.
The parser doesn't seem to be handling multipart/alternative correctly. Please see https://github.com/dkontyko/MimeParser/blob/adding_tests/Tests/MimeParserTests/EmailParsingTests.swift for an example. In the test email, the number of alternative parts is 3, but the parser only parses 2, and testCanParseEmailWithMultipartAlternative fails.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.