id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1 value |
|---|---|---|
c180000 |
tolist = append(tolist, cc)
}
for _, bcc := range m.Bcc {
tolist = append(tolist, bcc)
}
return tolist
} | |
c180001 | } else {
ext := filepath.Ext(attachment.Filename)
mimetype := mime.TypeByExtension(ext)
if mimetype != "" {
mime := fmt.Sprintf("Content-Type: %s\r\n", mimetype)
buf.WriteString(mime)
} else {
buf.WriteString("Content-Type: application/octet-stream\r\n")
}
buf.WriteString("Content-Transfer-Encoding: base64\r\n")
buf.WriteString("Content-Disposition: attachment; filename=\"=?UTF-8?B?")
buf.WriteString(coder.EncodeToString([]byte(attachment.Filename)))
buf.WriteString("?=\"\r\n\r\n")
b := make([]byte, base64.StdEncoding.EncodedLen(len(attachment.Data)))
base64.StdEncoding.Encode(b, attachment.Data)
// write base64 content in lines of up to 76 chars
for i, l := 0, len(b); i < l; i++ {
buf.WriteByte(b[i])
if (i+1)%76 == 0 {
buf.WriteString("\r\n")
}
}
}
buf.WriteString("\r\n--" + boundary)
}
buf.WriteString("--")
}
return buf.Bytes()
} | |
c180002 | auth, m.From.Address, m.Tolist(), m.Bytes())
} | |
c180003 | }
return decodeHeader(e.header.Get(name))
} | |
c180004 | v := range rawValues {
values = append(values, decodeHeader(v))
}
return values
} | |
c180005 |
e.header.Set(name, mime.BEncoding.Encode("utf-8", v))
continue
}
e.header.Add(name, mime.BEncoding.Encode("utf-8", v))
}
return nil
} | |
c180006 | fmt.Errorf("Provide non-empty header name")
}
e.header.Add(name, mime.BEncoding.Encode("utf-8", value))
return nil
} | |
c180007 | "" {
return fmt.Errorf("Provide non-empty header name")
}
e.header.Del(name)
return nil
} | |
c180008 | switch {
case err == nil:
// carry on
case err.Error() == "mail: expected comma":
ret, err = mail.ParseAddressList(ensureCommaDelimitedAddresses(str))
if err != nil {
return nil, err
}
default:
return nil, err
}
return ret, nil
} | |
c180009 |
e.Attachments,
e.Inlines,
e.OtherParts,
e.Errors,
e.header,
}
return newEnvelope
} | |
c180010 |
return nil, errors.WithMessage(err, "Failed to ReadParts")
}
return EnvelopeFromPart(root)
} | |
c180011 |
e.Text = ""
p := e.Root.BreadthMatchFirst(matchHTMLBodyPart)
p.addError(
ErrorPlainTextFromHTML,
"Failed to downconvert HTML: %v",
err)
}
}
// Copy part errors into Envelope.
if e.Root != nil {
_ = e.Root.DepthMatchAll(func(part *Part) bool {
// Using DepthMatchAll to traverse all parts, don't care about result.
for i := range part.Errors {
// Range index is needed to get the correct address, because range value points to
// a locally scoped variable.
e.Errors = append(e.Errors, part.Errors[i])
}
return false
})
}
return e, nil
} | |
c180012 | if charset = coding.FindCharsetInHTML(rawHTML); charset != "" {
// Found charset in HTML
if convHTML, err := coding.ConvertToUTF8String(charset, root.Content); err == nil {
// Successful conversion
e.HTML = convHTML
} else {
// Conversion failed
root.addWarning(ErrorCharsetConversion, err.Error())
}
}
// Converted from charset in HTML
return nil
}
} else {
e.Text = string(root.Content)
}
return nil
} | |
c180013 | // Locate HTML body
p := root.BreadthMatchFirst(matchHTMLBodyPart)
if p != nil {
e.HTML += string(p.Content)
}
// Locate attachments
e.Attachments = root.BreadthMatchAll(func(p *Part) bool {
return p.Disposition == cdAttachment || p.ContentType == ctAppOctetStream
})
// Locate inlines
e.Inlines = root.BreadthMatchAll(func(p *Part) bool {
return p.Disposition == cdInline && !strings.HasPrefix(p.ContentType, ctMultipartPrefix)
})
// Locate others parts not considered in attachments or inlines
e.OtherParts = root.BreadthMatchAll(func(p *Part) bool {
if strings.HasPrefix(p.ContentType, ctMultipartPrefix) {
return false
}
if p.Disposition != "" {
return false
}
if p.ContentType == ctAppOctetStream {
return false
}
return p.ContentType != ctTextPlain && p.ContentType != ctTextHTML
})
return nil
} | |
c180014 | p.ContentType == ctTextHTML && p.Disposition != cdAttachment
} | |
c180015 | escapeSequence = true
sb.WriteRune(r)
continue
}
} else {
if r == '@' {
inDomain = true
sb.WriteRune(r)
continue
}
if inDomain {
if r == ';' {
sb.WriteRune(r)
break
}
if r == ',' {
inDomain = false
sb.WriteRune(r)
continue
}
if r == ' ' {
inDomain = false
sb.WriteRune(',')
sb.WriteRune(r)
continue
}
}
}
sb.WriteRune(r)
}
return sb.String()
} | |
c180016 | MailBuilder {
p.date = date
return p
} | |
c180017 | mail.Address{Name: name, Address: addr}
return p
} | |
c180018 | p.subject = subject
return p
} | |
c180019 | append(p.to, mail.Address{Name: name, Address: addr})
return p
} | |
c180020 | MailBuilder {
p.to = to
return p
} | |
c180021 | append(p.cc, mail.Address{Name: name, Address: addr})
return p
} | |
c180022 | MailBuilder {
p.cc = cc
return p
} | |
c180023 | mail.Address{Name: name, Address: addr}
return p
} | |
c180024 | := range p.header {
h[k] = v
}
h.Add(name, value)
p.header = h
return p
} | |
c180025 |
part.Disposition = cdAttachment
p.attachments = append(p.attachments, part)
return p
} | |
c180026 | }
name := filepath.Base(path)
ctype := mime.TypeByExtension(filepath.Ext(name))
return p.AddAttachment(b, ctype, name)
} | |
c180027 | fileName
part.Disposition = cdInline
part.ContentID = contentID
p.inlines = append(p.inlines, part)
return p
} | |
c180028 | reflect.DeepEqual(p, o)
} | |
c180029 | p.Boundary + "--")
marker := endMarker[:len(endMarker)-2]
c := p.FirstChild
for c != nil {
b.Write(marker)
b.Write(crnl)
if err := c.Encode(b); err != nil {
return err
}
c = c.NextSibling
}
b.Write(endMarker)
b.Write(crnl)
return b.Flush()
} | |
c180030 | encv = mime.QEncoding.Encode(utf8, v)
}
// _ used to prevent early wrapping
wb := stringutil.Wrap(76, k, ":_", encv, "\r\n")
wb[len(k)+1] = ' '
b.Write(wb)
}
}
} | |
c180031 | err != nil {
return err
}
b.Write(crnl)
text = text[lineLen:]
}
case teQuoted:
qp := quotedprintable.NewWriter(b)
if _, err = qp.Write(p.Content); err != nil {
return err
}
err = qp.Close()
default:
_, err = b.Write(p.Content)
}
return err
} | |
c180032 | !quoteLineBreaks && (b == '\r' || b == '\n') {
continue
}
bincount++
if bincount >= threshold {
return teBase64
}
}
}
if bincount == 0 {
return te7Bit
}
return teQuoted
} | |
c180033 |
if v != "" {
p[k] = v
}
} | |
c180034 |
Errors: make([]error, 0),
r: r,
}
} | |
c180035 | // Stash parenthesis, they should not be encoded
prefix := ""
suffix := ""
if token[0] == '(' {
prefix = "("
token = token[1:]
}
if token[len(token)-1] == ')' {
suffix = ")"
token = token[:len(token)-1]
}
// Base64 encode token
output[i] = prefix + mime.BEncoding.Encode("UTF-8", decodeHeader(token)) + suffix
} else {
output[i] = token
}
}
// Return space separated tokens
return strings.Join(output, " ")
} | |
c180036 | if strings.Contains(mctype, `name=""`) {
mctype = strings.Replace(mctype, `name=""`, `name=" "`, -1)
}
mtype, params, err = mime.ParseMediaType(mctype)
if err != nil {
// If the media parameter has special characters, ensure that it is quoted.
mtype, params, err = mime.ParseMediaType(fixUnquotedSpecials(mctype))
if err != nil {
return "", nil, nil, errors.WithStack(err)
}
}
}
}
if mtype == ctPlaceholder {
mtype = ""
}
for name, value := range params {
if value != pvPlaceholder {
continue
}
invalidParams = append(invalidParams, name)
delete(params, name)
}
return mtype, params, invalidParams, err
} | |
c180037 | and is therefor an invalid attribute.
// Discard the pair.
continue
}
}
mtype += p
// Only terminate with semicolon if not the last parameter and if it doesn't already have a
// semicolon.
if i != len(parts)-1 && !strings.HasSuffix(mtype, ";") {
mtype += ";"
}
}
if strings.HasSuffix(mtype, ";") {
mtype = mtype[:len(mtype)-1]
}
return mtype
} | |
c180038 | all other multipart should
// be treated as multipart/mixed
return strings.HasPrefix(mediatype, ctMultipartPrefix)
} | |
c180039 |
mediatype, _, _, _ := parseMediaType(root.Header.Get(hnContentType))
mediatype = strings.ToLower(mediatype)
if mediatype != ctTextPlain && mediatype != ctTextHTML {
return true
}
}
return isBin
} | |
c180040 | order
for q.Len() > 0 {
e := q.Front()
p := e.Value.(*Part)
if matcher(p) {
return p
}
q.Remove(e)
c := p.FirstChild
for c != nil {
q.PushBack(c)
c = c.NextSibling
}
}
return nil
} | |
c180041 | in that order
for q.Len() > 0 {
e := q.Front()
p := e.Value.(*Part)
if matcher(p) {
matches = append(matches, p)
}
q.Remove(e)
c := p.FirstChild
for c != nil {
q.PushBack(c)
c = c.NextSibling
}
}
return matches
} | |
c180042 | if c != nil {
p = c
} else {
for p.NextSibling == nil {
if p == root {
return nil
}
p = p.Parent
}
p = p.NextSibling
}
}
} | |
c180043 | p)
}
c := p.FirstChild
if c != nil {
p = c
} else {
for p.NextSibling == nil {
if p == root {
return matches
}
p = p.Parent
}
p = p.NextSibling
}
}
} | |
c180044 | runes.Remove(runes.In(unicode.Mn)), runes.Map(mapLatinSpecial),
norm.NFC)
r, _, _ := transform.String(tr, s)
return r
} | |
c180045 |
Header: make(textproto.MIMEHeader),
ContentType: contentType,
}
} | |
c180046 | return
}
current.NextSibling = child
}
}
// Update all new first-level children Parent pointers.
for c := child; c != nil; c = c.NextSibling {
if c == c.NextSibling {
// Prevent infinite loop.
return
}
c.Parent = p
}
} | |
c180047 | strings.HasPrefix(p.ContentType, "text/") ||
strings.HasPrefix(p.ContentType, ctMultipartPrefix)
} | |
c180048 | minvalidParams, err := parseMediaType(ctype)
if err != nil {
return err
}
if mtype == "" && len(mparams) > 0 {
p.addWarning(
ErrorMissingContentType,
"Content-Type header has parameters but no content type")
}
for i := range minvalidParams {
p.addWarning(
ErrorMalformedHeader,
"Content-Type header has malformed parameter %q",
minvalidParams[i])
}
p.ContentType = mtype
// Set disposition, filename, charset if available.
p.setupContentHeaders(mparams)
p.Boundary = mparams[hpBoundary]
p.ContentID = coding.FromIDHeader(header.Get(hnContentID))
return nil
} | |
c180049 | p.FileName = decodeHeader(mediaParams[hpFile])
}
if p.Charset == "" {
p.Charset = mediaParams[hpCharset]
}
if p.FileModDate.IsZero() {
p.FileModDate, _ = time.Parse(time.RFC822, mediaParams[hpModDate])
}
} | |
c180050 |
return nil, errors.WithStack(err)
}
// Restore r.
r = bytes.NewReader(buf)
if cs == nil || cs.Confidence < minCharsetConfidence {
// Low confidence, use declared character set.
return p.convertFromStatedCharset(r), nil
}
// Confidence exceeded our threshold, use detected character set.
if p.Charset != "" && !strings.EqualFold(cs.Charset, p.Charset) {
p.addWarning(ErrorCharsetDeclaration,
"declared charset %q, detected %q, confidence %d",
p.Charset, cs.Charset, cs.Confidence)
}
reader, err := coding.NewCharsetReader(cs.Charset, r)
if err != nil {
// Failed to get a conversion reader.
p.addWarning(ErrorCharsetConversion, err.Error())
} else {
r = reader
p.OrigCharset = p.Charset
p.Charset = cs.Charset
}
return r, nil
} | |
c180051 | p.Content,
Epilogue: p.Epilogue,
}
newPart.FirstChild = p.FirstChild.Clone(newPart)
newPart.NextSibling = p.NextSibling.Clone(parent)
return newPart
} | |
c180052 | err != nil {
return nil, err
}
if strings.HasPrefix(root.ContentType, ctMultipartPrefix) {
// Content is multipart, parse it.
err = parseParts(root, br)
if err != nil {
return nil, err
}
} else {
// Content is text or data, decode it.
if err := root.decodeContent(br); err != nil {
return nil, err
}
}
return root, nil
} | |
c180053 | // There are no more Parts. The error must belong to the parent, because this
// part doesn't exist.
parent.addWarning(ErrorMissingBoundary, "Boundary %q was not closed correctly",
parent.Boundary)
break
}
// The error is already wrapped with a stack, so only adding a message here.
// TODO: Once `errors` releases a version > v0.8.0, change to use errors.WithMessagef()
return errors.WithMessage(err, fmt.Sprintf("error at boundary %v", parent.Boundary))
}
} else if err != nil {
return err
}
// Insert this Part into the MIME tree.
parent.AddChild(p)
if p.Boundary == "" {
// Content is text or data, decode it.
if err := p.decodeContent(bbr); err != nil {
return err
}
} else {
// Content is another multipart.
err = parseParts(p, bbr)
if err != nil {
return err
}
}
}
// Store any content following the closing boundary marker into the epilogue.
epilogue, err := ioutil.ReadAll(reader)
if err != nil {
return errors.WithStack(err)
}
parent.Epilogue = epilogue
// If a Part is "multipart/" Content-Type, it will have .0 appended to its PartID
// i.e. it is the root of its MIME Part subtree.
if !firstRecursion {
parent.PartID += ".0"
}
return nil
} | |
c180054 | uuid[6]&^0xf0 | 0x40
return fmt.Sprintf("%x-%x-%x-%x-%x", uuid[0:4], uuid[4:6], uuid[6:8], uuid[8:10], uuid[10:])
} | |
c180055 |
in: bufio.NewReader(r),
}
} | |
c180056 | return fmt.Sprintf("[%s] %s: %s", sev, e.Name, e.Detail)
} | |
c180057 | &Error{
name,
fmt.Sprintf(detailFmt, args...),
true,
})
} | |
c180058 | &Error{
name,
fmt.Sprintf(detailFmt, args...),
false,
})
} | |
c180059 | 0 // Length of current line
for i := 0; i < len(input); i++ {
ll++
switch input[i] {
case ' ', '\t':
ls = i
}
if ll >= max {
if ls >= 0 {
output = append(output, input[lw+1:ls]...)
output = append(output, '\r', '\n', ' ')
lw = ls // Jump over the space we broke on
ll = 1 // Count leading space above
// Rewind
i = lw + 1
ls = -1
}
}
}
return append(output, input[lw+1:]...)
} | |
c180060 |
reader := transform.NewReader(input, csentry.e.NewDecoder())
output, err := ioutil.ReadAll(reader)
if err != nil {
return "", err
}
return string(output), nil
} | |
c180061 | _, _ = buf.WriteString(", ")
}
_, _ = buf.WriteString(a.String())
}
return buf.String()
} | |
c180062 | fmt.Fprintf(md, format, args...)
} | |
c180063 |
md.Printf(" Content-ID: %s\n", a.ContentID)
}
}
md.Println()
md.H2("Inline List")
for _, a := range e.Inlines {
md.Printf("- %v (%v)\n", a.FileName, a.ContentType)
if a.ContentID != "" {
md.Printf(" Content-ID: %s\n", a.ContentID)
}
}
md.Println()
md.H2("Other Part List")
for _, a := range e.OtherParts {
md.Printf("- %v (%v)\n", a.FileName, a.ContentType)
if a.ContentID != "" {
md.Printf(" Content-ID: %s\n", a.ContentID)
}
}
md.Println()
md.H2("MIME Part Tree")
if e.Root == nil {
md.Println("Message was not MIME encoded")
} else {
FormatPart(md, e.Root, " ")
}
if len(e.Errors) > 0 {
md.Println()
md.H2("Errors")
for _, perr := range e.Errors {
md.Println("-", perr)
}
}
return md.Flush()
} | |
c180064 | indent
}
// Format and print this node
ctype := "MISSING TYPE"
if p.ContentType != "" {
ctype = p.ContentType
}
disposition := ""
if p.Disposition != "" {
disposition = fmt.Sprintf(", disposition: %s", p.Disposition)
}
filename := ""
if p.FileName != "" {
filename = fmt.Sprintf(", filename: %q", p.FileName)
}
errors := ""
if len(p.Errors) > 0 {
errors = fmt.Sprintf(" (errors: %v)", len(p.Errors))
}
fmt.Fprintf(w, "%s%s%s%s%s\n", myindent, ctype, disposition, filename, errors)
// Recurse
FormatPart(w, child, childindent)
FormatPart(w, sibling, indent)
} | |
c180065 | prefix: fullBoundary[1 : len(fullBoundary)-2],
final: fullBoundary[1:],
buffer: new(bytes.Buffer),
}
} | |
c180066 | 0
if peekEOF {
// No more peek space remaining and no boundary found
return 0, errors.WithStack(io.ErrUnexpectedEOF)
}
}
}
if nCopy > 0 {
if _, err = io.CopyN(b.buffer, b.r, int64(nCopy)); err != nil {
return 0, errors.WithStack(err)
}
}
n, err = b.buffer.Read(dest)
if err == io.EOF && !complete {
// Only the buffer is empty, not the boundaryReader
return n, nil
}
return n, err
} | |
c180067 | {
// Intentionally not wrapping with stack
return false, io.EOF
}
if b.partsRead == 0 {
// The first part didn't find the starting delimiter, burn off any preamble in front of
// the boundary
continue
}
b.finished = true
return false, errors.Errorf("expecting boundary %q, got %q", string(b.prefix), string(line))
}
} | |
c180068 | err := parseReturningOffset(buf, offset)
return obj, err
} | |
c180069 |
case int32:
return assignInt(symbol, value.(int32))
case float64:
return assignDouble(symbol, value.(float64))
default:
return nil, errors.New("session assign: type is not supported")
}
} | |
c180070 | NewRClientWithAuth(host, port, "", "")
} | |
c180071 | if err != nil {
return nil, err
}
rClient := &roger{
address: addr,
user: user,
password: password,
}
if _, err = rClient.Eval("'Test session connection'"); err != nil {
return nil, err
}
return rClient, nil
} | |
c180072 | inflect.Camelize(identifier)
customGenerators[fakeType] = generator
} | |
c180073 | field := value.Field(i)
if field.CanSet() {
field.Set(fuzzValueFor(field.Kind()))
}
}
}
} | |
c180074 | }
for kind, function := range allGenerators() {
if fako == kind {
result = function
break
}
}
return result
} | |
c180075 | := o(opts); err != nil {
return err
}
}
return nil
} | |
c180076 | len(opts.Other))
for k, v := range opts.Other {
nopts.Other[k] = v
}
}
return nil
}
} | |
c180077 | memory (in case we end up hanging on to this for a while).
e.ch = nil
e.mu.Unlock()
} | |
c180078 | select {
case e.ch <- ev:
case <-e.ctx.Done():
case <-ctx.Done():
}
e.mu.Unlock()
} | |
c180079 | }
return &VariableEWMA{
decay: 2 / (age[0] + 1),
}
} | |
c180080 | e.count <= WARMUP_SAMPLES {
e.count = WARMUP_SAMPLES + 1
}
} | |
c180081 | u = prf.Sum(u[:0])
for j := range u {
t[j] ^= u[j]
}
iter--
}
keys[i] = append([]byte(nil), t...)
}
pwcheck := keys[2]
for i, v := range pwcheck[pwCheckSize:] {
pwcheck[i&(pwCheckSize-1)] ^= v
}
keys[2] = pwcheck[:pwCheckSize]
return keys
} | |
c180082 |
}
// not found, calculate keys
keys = calcKeys50(a.pass, salt, kdfCount)
// store in cache
copy(a.keyCache[1:], a.keyCache[:])
a.keyCache[0].kdfCount = kdfCount
a.keyCache[0].salt = append([]byte(nil), salt...)
a.keyCache[0].keys = keys
return keys, nil
} | |
c180083 | }
pwcheck := b.bytes(8)
sum := b.bytes(4)
csum := sha256.Sum256(pwcheck)
if bytes.Equal(sum, csum[:len(sum)]) && !bytes.Equal(pwcheck, keys[2]) {
return errBadPassword
}
return nil
} | |
c180084 | flags&file5EncCheckPresent > 0 {
if err := checkPassword(&b, keys); err != nil {
return err
}
}
if flags&file5EncUseMac > 0 {
a.checksum.key = keys[1]
}
return nil
} | |
c180085 | if flags&enc5CheckPresent > 0 {
if err := checkPassword(&b, keys); err != nil {
return err
}
}
a.blockKey = keys[0]
return nil
} | |
c180086 |
a.pass = []byte(password)
a.buf = make([]byte, 100)
return a
} | |
c180087 | }
// p is not large enough to process a block, use outbuf instead
n, cr.err = cr.read(cr.outbuf[:cap(cr.outbuf)])
cr.outbuf = cr.outbuf[:n]
cr.n = 0
}
// read blocks into p
return cr.read(p)
} | |
c180088 | outbuf
var n int
n, cr.err = cr.read(cr.outbuf[:cap(cr.outbuf)])
cr.outbuf = cr.outbuf[:n]
cr.n = 0
}
} | |
c180089 | r, mode: mode}
cr.outbuf = make([]byte, 0, mode.BlockSize())
cr.inbuf = make([]byte, 0, mode.BlockSize())
return cr
} | |
c180090 |
}
mode := cipher.NewCBCDecrypter(block, iv)
return newCipherBlockReader(r, mode)
} | |
c180091 | {
return &limitedByteReader{limitedReader{r, n, io.ErrUnexpectedEOF}, r}
} | |
c180092 | != 0 {
m |= os.ModeSticky
}
if f.Attributes&0x400 != 0 {
m |= os.ModeSetgid
}
if f.Attributes&0x800 != 0 {
m |= os.ModeSetuid
}
// Check for additional file types.
if f.Attributes&0xF000 == 0xA000 {
m |= os.ModeSymlink
}
return m
} | |
c180093 | }
if h.first || h.Name != f.h.Name {
return errInvalidFileBlock
}
f.h = h
return nil
} | |
c180094 | nil {
return nil, err
}
}
var err error
f.h, err = f.r.next() // get next file block
if err != nil {
if err == errArchiveEnd {
return nil, io.EOF
}
return nil, err
}
if !f.h.first {
return nil, errInvalidFileBlock
}
return f.h, nil
} | |
c180095 |
if err := f.nextBlockInFile(); err != nil {
return 0, err
}
n, err = f.r.Read(p) // read new block data
}
return n, err
} | |
c180096 | err == io.EOF && r.cksum != nil && !r.cksum.valid() {
return n, errBadFileChecksum
}
return n, err
} | |
c180097 |
}
if h.UnPackedSize >= 0 && !h.UnKnownSize {
// Limit reading to UnPackedSize as there may be padding
r.r = &limitedReader{r.r, h.UnPackedSize, errShortFile}
}
r.cksum = h.cksum
if r.cksum != nil {
r.r = io.TeeReader(r.r, h.cksum) // write file data to checksum as it is read
}
fh := new(FileHeader)
*fh = h.FileHeader
return fh, nil
} | |
c180098 | password)
if err != nil {
return nil, err
}
rr := new(Reader)
rr.init(fbr)
return rr, nil
} | |
c180099 |
if err != nil {
return nil, err
}
rc := new(ReadCloser)
rc.v = v
rc.Reader.init(v)
return rc, nil
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.