mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-15 00:01:25 -04:00
Compare commits
No commits in common. "77c89572e936ae785d60b66d29316a2c6257e810" and "638fbd0b78f3464b5cebcad26d3f18cb32183069" have entirely different histories.
77c89572e9
...
638fbd0b78
@ -7,6 +7,7 @@ package charset
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
@ -20,16 +21,12 @@ import (
|
|||||||
var defaultWordRegexp = regexp.MustCompile(`(-?\d*\.\d\w*)|([^\` + "`" + `\~\!\@\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s\x00-\x1f]+)`)
|
var defaultWordRegexp = regexp.MustCompile(`(-?\d*\.\d\w*)|([^\` + "`" + `\~\!\@\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s\x00-\x1f]+)`)
|
||||||
|
|
||||||
func NewEscapeStreamer(locale translation.Locale, next HTMLStreamer, allowed ...rune) HTMLStreamer {
|
func NewEscapeStreamer(locale translation.Locale, next HTMLStreamer, allowed ...rune) HTMLStreamer {
|
||||||
allowedM := make(map[rune]bool, len(allowed))
|
|
||||||
for _, v := range allowed {
|
|
||||||
allowedM[v] = true
|
|
||||||
}
|
|
||||||
return &escapeStreamer{
|
return &escapeStreamer{
|
||||||
escaped: &EscapeStatus{},
|
escaped: &EscapeStatus{},
|
||||||
PassthroughHTMLStreamer: *NewPassthroughStreamer(next),
|
PassthroughHTMLStreamer: *NewPassthroughStreamer(next),
|
||||||
locale: locale,
|
locale: locale,
|
||||||
ambiguousTables: AmbiguousTablesForLocale(locale),
|
ambiguousTables: AmbiguousTablesForLocale(locale),
|
||||||
allowed: allowedM,
|
allowed: allowed,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +35,7 @@ type escapeStreamer struct {
|
|||||||
escaped *EscapeStatus
|
escaped *EscapeStatus
|
||||||
locale translation.Locale
|
locale translation.Locale
|
||||||
ambiguousTables []*AmbiguousTable
|
ambiguousTables []*AmbiguousTable
|
||||||
allowed map[rune]bool
|
allowed []rune
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *escapeStreamer) EscapeStatus() *EscapeStatus {
|
func (e *escapeStreamer) EscapeStatus() *EscapeStatus {
|
||||||
@ -260,7 +257,7 @@ func (e *escapeStreamer) runeTypes(runes ...rune) (types []runeType, confusables
|
|||||||
runeCounts.numBrokenRunes++
|
runeCounts.numBrokenRunes++
|
||||||
case r == ' ' || r == '\t' || r == '\n':
|
case r == ' ' || r == '\t' || r == '\n':
|
||||||
runeCounts.numBasicRunes++
|
runeCounts.numBasicRunes++
|
||||||
case e.allowed[r]:
|
case e.isAllowed(r):
|
||||||
if r > 0x7e || r < 0x20 {
|
if r > 0x7e || r < 0x20 {
|
||||||
types[i] = nonBasicASCIIRuneType
|
types[i] = nonBasicASCIIRuneType
|
||||||
runeCounts.numNonConfusingNonBasicRunes++
|
runeCounts.numNonConfusingNonBasicRunes++
|
||||||
@ -286,3 +283,16 @@ func (e *escapeStreamer) runeTypes(runes ...rune) (types []runeType, confusables
|
|||||||
}
|
}
|
||||||
return types, confusables, runeCounts
|
return types, confusables, runeCounts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *escapeStreamer) isAllowed(r rune) bool {
|
||||||
|
if len(e.allowed) == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if len(e.allowed) == 1 {
|
||||||
|
return e.allowed[0] == r
|
||||||
|
}
|
||||||
|
|
||||||
|
return sort.Search(len(e.allowed), func(i int) bool {
|
||||||
|
return e.allowed[i] >= r
|
||||||
|
}) >= 0
|
||||||
|
}
|
||||||
|
@ -99,9 +99,6 @@ func GetDefaultMergeMessage(baseGitRepo *git.Repository, pr *issues_model.PullRe
|
|||||||
}
|
}
|
||||||
for _, ref := range refs {
|
for _, ref := range refs {
|
||||||
if ref.RefAction == references.XRefActionCloses {
|
if ref.RefAction == references.XRefActionCloses {
|
||||||
if err := ref.LoadIssue(); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
closeIssueIndexes = append(closeIssueIndexes, fmt.Sprintf("%s %s%d", closeWord, issueReference, ref.Issue.Index))
|
closeIssueIndexes = append(closeIssueIndexes, fmt.Sprintf("%s %s%d", closeWord, issueReference, ref.Issue.Index))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user