Comments (10)
I have found that replacing the DecodeQP method with this...
public static string DecodeQuotedPrintables(string input)
{
var occurences = new Regex(@"=[0-9A-Z]{2}", RegexOptions.Multiline);
var matches = occurences.Matches(input);
foreach (Match match in matches)
{
char hexChar = (char)Convert.ToInt32(match.Groups[0].Value.Substring(1), 16);
input = input.Replace(match.Groups[0].Value, hexChar.ToString());
}
return input.Replace("=\r\n", "");
}
resolves the issue. I don't know enough about QP to know what is correct and what isn't.
from s22.imap.
I am having a similar issue. When saving some messages, there is no body when it gets saved. Some work, some don't. The attachments are coming. In said message, there doesn't seem to be quoted printable. The messages that work do have this.
from s22.imap.
Previous post removed, incorrect fix. indexer (i) + 2 was correct.
from s22.imap.
On 12/5/2012 5:34 AM, trickbooter wrote:
Previous post removed, incorrect fix. indexer (i) + 2 was correct.
—
Reply to this email directly or view it on GitHub
#21 (comment).Is there something i can do on my end to fix this issue? By your
comment, I have to override QPDecode.
Thanks,
Jason
from s22.imap.
Thanks for reporting, I'll look into it. Can you post an example mail message (the "raw" message with mail headers and body) or forward one to me so that I can re-produce the problem?
from s22.imap.
I did read that QP encodes to a certain length (80 chars?) and that a special sequence is used to denote this, =\r\n. This needs to be dealt with. For me, this was the crux of the issue (see code below).
internal static string QPDecode(string value, Encoding encoding) {
try {
using (MemoryStream m = new MemoryStream()) {
for (int i = 0; i < value.Length; i++) {
if(value[i] == '=' && value[i+1] == '\r' && value[i+2]=='\n') {
i = i + 2;
} else if (value[i] == '=') {
string hex = value.Substring(i + 1, 2);
m.WriteByte(Convert.ToByte(hex, 16));
i = i + 2;
} else {
m.WriteByte(Convert.ToByte(value[i]));
}
}
return encoding.GetString(m.ToArray());
}
} catch {
throw new FormatException("value is not a valid quoted-printable " +
"encoded string");
}
}
Using the existing method, the code decodes my message as (snipped to preserve confidentiality and shown as the c# raw string hence the \ escape char on the "...)
\r\n\r\n<rm xmlns=3D"http://www
after replacing the QPDecode' method with the one shown above, the same message decodes as follows...
\r\n\r\n<rm xmlns="http://www
I can forward you an email if you like, but I'd rather not post an email to this forum as it will reveal some private info. Have you got an email I can send to in confidence?
Many Thanks
Paul
from s22.imap.
Hi! That's a Soft Line Breaks. Non-significant line break.
Check out Rule #5 (Soft Line Breaks)
in RFC 1521 (http://www.ietf.org/rfc/rfc1521.txt).
You should just skip \r\n
(or \n
) in QPDecode:
string hex = value.Substring(i + 1, 2);
if (hex != Environment.NewLine)
m.WriteByte(Convert.ToByte(hex, 16));
i = i + 2;
Or could be New Line in value
string represented as \n
, while Environment.NewLine
is \r\n
? If so, then code should be:
string hex = value.Substring(i + 1, 2);
if (hex=="\r\n")
{
i += 2;
}
else if (hex.StartsWith("\n"))
{
i += 1;
}
else
{
m.WriteByte(Convert.ToByte(hex, 16));
i += 2;
}
from s22.imap.
Agreed, I understand what they are. However, the standard QP Decode method
works for my incoming emails only after I made the changes I presented in
my last email.
On 13 January 2013 11:50, rocknroll-mind [email protected] wrote:
Hi! That's a Soft Line Breaks. Non-significant line break.
Check out Rule #5 (Soft Line Breaks) in RFC 1521 (
http://www.ietf.org/rfc/rfc1521.txt).
You should just skip \r\n (or \n) in QPDecode:string hex = value.Substring(i + 1, 2); if (hex != Environment.NewLine) m.WriteByte(Convert.ToByte(hex, 16)); i = i + 2;
Or could be New Line in value string represented as \n, while
Environment.NewLine is \r\n? If so, then code should be:string hex = value.Substring(i + 1, 2); if (hex=="\r\n") { i += 2; } else if (hex.StartsWith("\n")) { i += 1; } else { m.WriteByte(Convert.ToByte(hex, 16)); i += 2; }
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-12192661.
from s22.imap.
You are right, I just submitted a patch to address it.
from s22.imap.
Thanks. It is an excellent library. Well maintain, functionally coded.
On Saturday, 26 January 2013 at 15:31, smiley22 wrote:
You are right, I just submitted a patch to address it.
—
Reply to this email directly or view it on GitHub (#21 (comment)).
from s22.imap.
Related Issues (20)
- Error “xm007 bad command argument 11” while marking outlook email as read from Scheduler not at manual run
- How can check the status of Message if is seen or unseen
- Attachments from iPhones don't always populate the Attachments collection HOT 2
- SearchCondition.SentSince seems not working HOT 1
- Low file size attachment is not found
- No type "Mailmessage" in Mono C# .net core linux application HOT 1
- Where are attachments after downloading ?
- Network connection lost while retrieving a mail message HOT 1
- SCRAM-SHA-1-PLUS + SCRAM-SHA-224(-PLUS) + SCRAM-SHA-256(-PLUS) + SCRAM-SHA-384(-PLUS) + SCRAM-SHA-512(-PLUS) + SCRAM-SHA3-512(-PLUS) supports
- Move this project to new dev team?
- inline file
- Intermittent freezing on Search
- DeleteMessage doesn't delete the message
- Documentation is not available - 404 error HOT 1
- xm002 NO SELECT Unsafe Login. Please contact [email protected] for help HOT 1
- Can not login to gmail HOT 1
- Connection doesn't restart after disruption to internet connection
- How to read email with 'Reply-To' position email account
- Is there a save option for the message itself as a *.eml file
- Error getting value from 'ReadTimeout' on 'System.IO.MemoryStream'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from s22.imap.