Update godeps for etcd 3.0.4

This commit is contained in:
Timothy St. Clair
2016-07-22 13:54:40 -05:00
parent 456c43c22d
commit 5f008faa8b
457 changed files with 25492 additions and 10481 deletions

View File

@@ -167,12 +167,17 @@ func lineBreak(p *parser, out *bytes.Buffer, data []byte, offset int) int {
out.Truncate(eol)
precededByTwoSpaces := offset >= 2 && data[offset-2] == ' ' && data[offset-1] == ' '
precededByBackslash := offset >= 1 && data[offset-1] == '\\' // see http://spec.commonmark.org/0.18/#example-527
precededByBackslash = precededByBackslash && p.flags&EXTENSION_BACKSLASH_LINE_BREAK != 0
// should there be a hard line break here?
if p.flags&EXTENSION_HARD_LINE_BREAK == 0 && !precededByTwoSpaces {
if p.flags&EXTENSION_HARD_LINE_BREAK == 0 && !precededByTwoSpaces && !precededByBackslash {
return 0
}
if precededByBackslash && eol > 0 {
out.Truncate(eol - 1)
}
p.r.LineBreak(out)
return 1
}
@@ -186,6 +191,13 @@ const (
linkInlineFootnote
)
func isReferenceStyleLink(data []byte, pos int, t linkType) bool {
if t == linkDeferredFootnote {
return false
}
return pos < len(data)-1 && data[pos] == '[' && data[pos+1] != '^'
}
// '[': parse a link or an image or a footnote
func link(p *parser, out *bytes.Buffer, data []byte, offset int) int {
// no links allowed inside regular links, footnote, and deferred footnotes
@@ -193,28 +205,35 @@ func link(p *parser, out *bytes.Buffer, data []byte, offset int) int {
return 0
}
// [text] == regular link
var t linkType
switch {
// special case: ![^text] == deferred footnote (that follows something with
// an exclamation point)
case p.flags&EXTENSION_FOOTNOTES != 0 && len(data)-1 > offset && data[offset+1] == '^':
t = linkDeferredFootnote
// ![alt] == image
case offset > 0 && data[offset-1] == '!':
t = linkImg
// ^[text] == inline footnote
// [^refId] == deferred footnote
var t linkType
if offset > 0 && data[offset-1] == '!' {
t = linkImg
} else if p.flags&EXTENSION_FOOTNOTES != 0 {
case p.flags&EXTENSION_FOOTNOTES != 0:
if offset > 0 && data[offset-1] == '^' {
t = linkInlineFootnote
} else if len(data)-1 > offset && data[offset+1] == '^' {
t = linkDeferredFootnote
}
// [text] == regular link
default:
t = linkNormal
}
data = data[offset:]
var (
i = 1
noteId int
title, link []byte
textHasNl = false
i = 1
noteId int
title, link, altContent []byte
textHasNl = false
)
if t == linkDeferredFootnote {
@@ -348,8 +367,9 @@ func link(p *parser, out *bytes.Buffer, data []byte, offset int) int {
i++
// reference style link
case i < len(data) && data[i] == '[':
case isReferenceStyleLink(data, i, t):
var id []byte
altContentConsidered := false
// look for the id
i++
@@ -379,22 +399,24 @@ func link(p *parser, out *bytes.Buffer, data []byte, offset int) int {
id = b.Bytes()
} else {
id = data[1:txtE]
altContentConsidered = true
}
} else {
id = data[linkB:linkE]
}
// find the reference with matching id (ids are case-insensitive)
key := string(bytes.ToLower(id))
lr, ok := p.refs[key]
// find the reference with matching id
lr, ok := p.getRef(string(id))
if !ok {
return 0
}
// keep link and title from reference
link = lr.link
title = lr.title
if altContentConsidered {
altContent = lr.text
}
i++
// shortcut reference style link or reference or inline footnote
@@ -423,7 +445,6 @@ func link(p *parser, out *bytes.Buffer, data []byte, offset int) int {
}
}
key := string(bytes.ToLower(id))
if t == linkInlineFootnote {
// create a new reference
noteId = len(p.notes) + 1
@@ -453,7 +474,7 @@ func link(p *parser, out *bytes.Buffer, data []byte, offset int) int {
title = ref.title
} else {
// find the reference with matching id
lr, ok := p.refs[key]
lr, ok := p.getRef(string(id))
if !ok {
return 0
}
@@ -505,7 +526,11 @@ func link(p *parser, out *bytes.Buffer, data []byte, offset int) int {
// call the relevant rendering function
switch t {
case linkNormal:
p.r.Link(out, uLink, title, content.Bytes())
if len(altContent) > 0 {
p.r.Link(out, uLink, title, altContent)
} else {
p.r.Link(out, uLink, title, content.Bytes())
}
case linkImg:
outSize := out.Len()
@@ -535,12 +560,33 @@ func link(p *parser, out *bytes.Buffer, data []byte, offset int) int {
return i
}
func (p *parser) inlineHtmlComment(out *bytes.Buffer, data []byte) int {
if len(data) < 5 {
return 0
}
if data[0] != '<' || data[1] != '!' || data[2] != '-' || data[3] != '-' {
return 0
}
i := 5
// scan for an end-of-comment marker, across lines if necessary
for i < len(data) && !(data[i-2] == '-' && data[i-1] == '-' && data[i] == '>') {
i++
}
// no end-of-comment marker
if i >= len(data) {
return 0
}
return i + 1
}
// '<' when tags or autolinks are allowed
func leftAngle(p *parser, out *bytes.Buffer, data []byte, offset int) int {
data = data[offset:]
altype := LINK_TYPE_NOT_AUTOLINK
end := tagLength(data, &altype)
if size := p.inlineHtmlComment(out, data); size > 0 {
end = size
}
if end > 2 {
if altype != LINK_TYPE_NOT_AUTOLINK {
var uLink bytes.Buffer
@@ -622,10 +668,7 @@ func entity(p *parser, out *bytes.Buffer, data []byte, offset int) int {
func linkEndsWithEntity(data []byte, linkEnd int) bool {
entityRanges := htmlEntity.FindAllIndex(data[:linkEnd], -1)
if entityRanges != nil && entityRanges[len(entityRanges)-1][1] == linkEnd {
return true
}
return false
return entityRanges != nil && entityRanges[len(entityRanges)-1][1] == linkEnd
}
func autoLink(p *parser, out *bytes.Buffer, data []byte, offset int) int {
@@ -757,9 +800,20 @@ func isEndOfLink(char byte) bool {
return isspace(char) || char == '<'
}
var validUris = [][]byte{[]byte("http://"), []byte("https://"), []byte("ftp://"), []byte("mailto://"), []byte("/")}
var validUris = [][]byte{[]byte("http://"), []byte("https://"), []byte("ftp://"), []byte("mailto://")}
var validPaths = [][]byte{[]byte("/"), []byte("./"), []byte("../")}
func isSafeLink(link []byte) bool {
for _, path := range validPaths {
if len(link) >= len(path) && bytes.Equal(link[:len(path)], path) {
if len(link) == len(path) {
return true
} else if isalnum(link[len(path)]) {
return true
}
}
}
for _, prefix := range validUris {
// TODO: handle unicode here
// case-insensitive prefix test
@@ -887,7 +941,7 @@ func isMailtoAutoLink(data []byte) int {
// look for the next emph char, skipping other constructs
func helperFindEmphChar(data []byte, c byte) int {
i := 1
i := 0
for i < len(data) {
for i < len(data) && data[i] != c && data[i] != '`' && data[i] != '[' {
@@ -896,15 +950,14 @@ func helperFindEmphChar(data []byte, c byte) int {
if i >= len(data) {
return 0
}
if data[i] == c {
return i
}
// do not count escaped chars
if i != 0 && data[i-1] == '\\' {
i++
continue
}
if data[i] == c {
return i
}
if data[i] == '`' {
// skip a code span