private static int SkipQtextOrQuotedPair( string s, int index, int endIndex, QuotedStringRule rule) { if (index >= endIndex) { return index; } int i2; if (rule == QuotedStringRule.Http) { char c = s[index]; // NOTE: Space and tab were handled earlier; // bytes higher than 0x7f are part of obs-text if (c < 0x100 && c >= 0x21 && c != 0x7F && c != '\\' && c != '"') { return index + 1; } i2 = SkipQuotedPair(s, index, endIndex); return i2; } if (rule == QuotedStringRule.Rfc5322) { i2 = index; // qtext (RFC5322 sec. 3.2.1) if (i2 < endIndex) { char c = s[i2]; // Non-ASCII (allowed in internationalized email headers under // RFC6532) if ((c & 0xfc00) == 0xd800 && i2 + 1 < endIndex && s[i2 + 1] >= 0xdc00 && s[i2 + 1] <= 0xdfff) { i2 += 2; } else if ((c & 0xf800) == 0xd800) { // unchanged; it's a bare surrogate } else if (c >= 0x80) { ++i2; } if (c >= 33 && c <= 126 && c != '\\' && c != '"') { ++i2; } // obs-qtext (same as obs-ctext) if ((c < 0x20 && c != 0x00 && c != 0x09 && c != 0x0a && c != 0x0d) || c == 0x7f) { ++i2; } } if (index != i2) { return i2; } index = i2; i2 = HeaderParser.ParseQuotedPair(s, index, endIndex, null); return i2; } throw new ArgumentException(rule.ToString()); }
private static int skipQtextOrQuotedPair( string s, int index, int endIndex, QuotedStringRule rule) { if(index>=endIndex)return index; int i2; if(rule==QuotedStringRule.Http){ char c=s[index]; if(c<0x100 && c>=0x21 && c!='\\' && c!='"') return index+1; i2=skipQuotedPair(s,index,endIndex); if(index!=i2)return i2; return i2; } else if(rule==QuotedStringRule.Rfc5322){ i2=skipQtext(s,index,endIndex); if(index!=i2)return i2; index=i2; i2=skipQuotedPair(s,index,endIndex); if(index!=i2)return i2; return i2; } else if(rule==QuotedStringRule.Smtp){ char c=s[index]; if(c>=0x20 && c<=0x7E && c!='\\' && c!='"') return index+1; i2=skipQuotedPairSMTP(s,index,endIndex); if(index!=i2)return i2; return i2; } else throw new ArgumentException(rule.ToString()); }