// Token: 0x06000469 RID: 1129 RVA: 0x000193E4 File Offset: 0x000175E4 public static int FindNextOf(MimeScan.Token token, byte[] bytes, int start, int length, out int characterCount, bool allowUTF8) { int num = start - 1; int num2 = start + length; characterCount = 0; while (++num < num2 && (short)(MimeScan.Dictionary[(int)bytes[num]] & token) == 0) { if (allowUTF8 && bytes[num] >= 128) { int num3 = 0; if (MimeScan.IsUTF8NonASCII(bytes, num, num2, out num3)) { if ((short)((MimeScan.Token.Token | MimeScan.Token.Atom) & token) == 0) { num += num3 - 1; characterCount++; continue; } break; } } characterCount++; } return(num - start); }
// Token: 0x06000467 RID: 1127 RVA: 0x00019318 File Offset: 0x00017518 public static int FindEndOf(MimeScan.Token token, byte[] bytes, int start, int length, out int characterCount, bool allowUTF8) { int num = start - 1; int num2 = start + length; characterCount = 0; while (++num < num2) { if ((short)(MimeScan.Dictionary[(int)bytes[num]] & token) != 0) { characterCount++; } else { if (!allowUTF8 || bytes[num] < 128) { break; } int num3 = 0; if (!MimeScan.IsUTF8NonASCII(bytes, num, num2, out num3) || (short)((MimeScan.Token.Token | MimeScan.Token.Atom) & token) == 0) { break; } num += num3 - 1; characterCount++; } } return(num - start); }
public void ParseParameterValue(ref MimeStringList value, ref bool goodValue, bool handleISO2022) { MimeStringList mimeStringList = default(MimeStringList); goodValue = true; while (this.position != this.end || this.ParseNextLine()) { byte b = this.bytes[this.position]; if (b == 34) { value.Reset(); mimeStringList.Reset(); this.ParseQString(true, ref value, handleISO2022); return; } if (b == 40 || MimeScan.IsLWSP(b)) { this.ParseCFWS(true, ref mimeStringList, handleISO2022); } else { if (b == 59) { return; } int num = this.position; do { int num2 = 1; if (!MimeScan.IsToken(b)) { if (this.allowUTF8 && b >= 128) { if (!MimeScan.IsUTF8NonASCII(this.bytes, this.position, this.end, out num2)) { num2 = 1; goodValue = false; } } else { goodValue = false; } } this.position += num2; if (this.position == this.end) { break; } b = this.bytes[this.position]; }while (b != 59 && b != 40 && !MimeScan.IsLWSP(b)); value.TakeOverAppend(ref mimeStringList); value.AppendFragment(new MimeString(this.bytes, num, this.position - num)); } } }
// Token: 0x0600030A RID: 778 RVA: 0x000111C4 File Offset: 0x0000F3C4 private int EncodeRfc2231Segment(byte[] source, int sourceIndex, int maxValueLength, EncodingOptions encodingOptions) { byte[] array = new byte[maxValueLength * 4]; int count = 0; int num = 0; while (sourceIndex < source.Length) { int i = 1; byte b = source[sourceIndex]; bool flag = true; if (b >= 128) { if (encodingOptions.AllowUTF8 && MimeScan.IsUTF8NonASCII(source, sourceIndex, source.Length, out i)) { flag = false; } } else if (!MimeScan.IsSegmentEncodingRequired(b)) { flag = false; } if (flag) { if (num + 3 > maxValueLength) { break; } array[count++] = 37; array[count++] = MimeParameter.OctetEncoderMap[b >> 4]; array[count++] = MimeParameter.OctetEncoderMap[(int)(b & 15)]; num += 3; this.valueEncoded = true; sourceIndex++; } else { if (num + 1 > maxValueLength) { break; } while (i > 0) { array[count++] = source[sourceIndex++]; i--; } num++; } } this.valueFragments.AppendFragment(new MimeString(array, 0, count)); return(sourceIndex); }
private static long WriteToken(byte[] token, int tokenOffset, MimeStringLength tokenLength, Stream stream, ref MimeStringLength currentLineLength, ref Header.LineBuffer lineBuffer, ref bool autoAddedLastLWSP, bool allowUTF8) { long num = 0L; bool flag = token != null && tokenLength.InChars == 1 && MimeScan.IsFWSP(token[tokenOffset]); if (!flag && currentLineLength.InChars + lineBuffer.Length.InChars + tokenLength.InChars > 78 && lineBuffer.LengthTillLastLWSP.InBytes >= 0) { if (lineBuffer.LengthTillLastLWSP.InBytes > 0) { stream.Write(lineBuffer.Bytes, 0, lineBuffer.LengthTillLastLWSP.InBytes); num += (long)lineBuffer.LengthTillLastLWSP.InBytes; currentLineLength.IncrementBy(lineBuffer.LengthTillLastLWSP); } if (currentLineLength.InBytes > 0) { num += Header.WriteLineEnd(stream, ref currentLineLength); } if (autoAddedLastLWSP) { autoAddedLastLWSP = false; lineBuffer.LengthTillLastLWSP.IncrementBy(1); } if (lineBuffer.LengthTillLastLWSP.InBytes != lineBuffer.Length.InBytes) { Buffer.BlockCopy(lineBuffer.Bytes, lineBuffer.LengthTillLastLWSP.InBytes, lineBuffer.Bytes, 0, lineBuffer.Length.InBytes - lineBuffer.LengthTillLastLWSP.InBytes); lineBuffer.Length.DecrementBy(lineBuffer.LengthTillLastLWSP); if (lineBuffer.Length.InBytes > 0 && MimeScan.IsFWSP(lineBuffer.Bytes[0])) { lineBuffer.LengthTillLastLWSP.SetAs(0); } else { lineBuffer.LengthTillLastLWSP.SetAs(-1); } } else { lineBuffer.Length.SetAs(0); lineBuffer.LengthTillLastLWSP.SetAs(-1); } bool flag2 = false; if (lineBuffer.Length.InBytes > 0) { if (!MimeScan.IsFWSP(lineBuffer.Bytes[0])) { flag2 = true; } } else if (!flag) { flag2 = true; } if (flag2) { stream.Write(Header.LineStartWhitespace, 0, Header.LineStartWhitespace.Length); num += (long)Header.LineStartWhitespace.Length; currentLineLength.IncrementBy(Header.LineStartWhitespace.Length); } } if (currentLineLength.InBytes + lineBuffer.Length.InBytes + tokenLength.InBytes > 998) { if (lineBuffer.Length.InBytes > 0) { stream.Write(lineBuffer.Bytes, 0, lineBuffer.Length.InBytes); num += (long)lineBuffer.Length.InBytes; currentLineLength.IncrementBy(lineBuffer.Length); lineBuffer.Length.SetAs(0); autoAddedLastLWSP = false; lineBuffer.LengthTillLastLWSP.SetAs(-1); } if (token != null) { while (currentLineLength.InBytes + tokenLength.InBytes > 998) { int num2 = Math.Max(0, 998 - currentLineLength.InBytes); int num3 = 0; int num4 = 0; if (allowUTF8) { int num5; for (int i = 0; i < tokenLength.InBytes; i += num5) { byte b = token[tokenOffset + i]; num5 = 1; if (b >= 128 && !MimeScan.IsUTF8NonASCII(token, tokenOffset + i, tokenOffset + tokenLength.InBytes, out num5)) { num5 = 1; } if (num4 + num5 > num2) { break; } num3++; num4 += num5; } } else { num3 = num2; num4 = num2; } stream.Write(token, tokenOffset, num4); num += (long)num4; currentLineLength.IncrementBy(num3, num4); tokenOffset += num4; tokenLength.DecrementBy(num3, num4); num += Header.WriteLineEnd(stream, ref currentLineLength); if (!flag) { stream.Write(Header.LineStartWhitespace, 0, Header.LineStartWhitespace.Length); num += (long)Header.LineStartWhitespace.Length; currentLineLength.IncrementBy(Header.LineStartWhitespace.Length); } } } } if (token != null) { Buffer.BlockCopy(token, tokenOffset, lineBuffer.Bytes, lineBuffer.Length.InBytes, tokenLength.InBytes); if (flag && (lineBuffer.Length.InBytes == 0 || !MimeScan.IsFWSP(lineBuffer.Bytes[lineBuffer.Length.InBytes - 1]))) { autoAddedLastLWSP = false; lineBuffer.LengthTillLastLWSP.SetAs(lineBuffer.Length); } lineBuffer.Length.IncrementBy(tokenLength); } return(num); }