8000 [pull] main from miniflux:main by pull[bot] · Pull Request #221 · suhaoGe/miniflux · GitHub
[go: up one dir, main page]

Skip to content
Merged
8000
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions internal/reader/sanitizer/srcset.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ func ParseSrcSetAttribute(attributeValue string) (candidates imageCandidates) {
return nil
}

position := 0
for position < len(attributeValue) {
var position uint = 0
for position < uint(len(attributeValue)) {
position = skipWhileHTMLSpaceOrComma(attributeValue, position)
if position >= len(attributeValue) {
if position >= uint(len(attributeValue)) {
break
}

Expand Down Expand Up @@ -81,8 +81,8 @@ func ParseSrcSetAttribute(attributeValue string) (candidates imageCandidates) {

type descriptorParsingResult struct {
density float64
resourceWidth int
resourceHeight int
resourceWidth uint
resourceHeight uint
hasDensity bool
hasWidth bool
hasHeight bool
Expand All @@ -93,12 +93,12 @@ func (r *descriptorParsingResult) setDensity(value float64) {
r.hasDensity = true
}

func (r *descriptorParsingResult) setResourceWidth(value int) {
func (r *descriptorParsingResult) setResourceWidth(value uint) {
r.resourceWidth = value
r.hasWidth = true
}

func (r *descriptorParsingResult) setResourceHeight(value int) {
func (r *descriptorParsingResult) setResourceHeight(value uint) {
r.resourceHeight = value
r.hasHeight = true
}
Expand All @@ -108,7 +108,7 @@ func serializeDescriptor(result descriptorParsingResult) string {
return formatFloat(result.density) + "x"
}
if result.hasWidth {
return strconv.Itoa(result.resourceWidth) + "w"
return strconv.FormatUint(uint64(result.resourceWidth), 10) + "w"
}
return ""
}
Expand Down Expand Up @@ -166,28 +166,28 @@ const (
descriptorStateAfterToken
)

func tokenizeDescriptors(input string, start int) (tokens []string, newPosition int) {
func tokenizeDescriptors(input string, start uint) (tokens []string, newPosition uint) {
state := descriptorStateInitial
currentStart := start
currentSet := true
position := start

appendDescriptorAndReset := func(position int) {
appendDescriptorAndReset := func(position uint) {
if currentSet && position > currentStart {
tokens = append(tokens, input[currentStart:position])
}
currentSet = false
}

appendCharacter := func(position int) {
appendCharacter := func(position uint) {
if !currentSet {
currentStart = position
currentSet = true
}
}

for {
if position >= len(input) {
if position >= uint(len(input)) {
if state != descriptorStateAfterToken {
appendDescriptorAndReset(position)
}
Expand Down Expand Up @@ -233,7 +233,7 @@ func tokenizeDescriptors(input string, start int) (tokens []string, newPosition
}
}

func parseValidHTMLNonNegativeInteger(value string) (int, bool) {
func parseValidHTMLNonNegativeInteger(value string) (uint, bool) {
if value == "" {
return 0, false
}
Expand All @@ -244,12 +244,12 @@ func parseValidHTMLNonNegativeInteger(value string) (int, bool) {
}
}

parsed, err := strconv.Atoi(value)
parsed, err := strconv.ParseUint(value, 10, 0)
if err != nil {
return 0, false
}

return parsed, true
return uint(parsed), true
}

func parseValidHTMLFloatingPointNumber(value string) (float64, bool) {
Expand All @@ -272,22 +272,22 @@ func formatFloat(value float64) string {
return strconv.FormatFloat(value, 'g', -1, 64)
}

func skipWhileHTMLSpaceOrComma(value string, position int) int {
for position < len(value) && (isASCIIWhitespace(value[position]) || isComma(value[position])) {
func skipWhileHTMLSpaceOrComma(value string, position uint) uint {
for position < uint(len(value)) && (isASCIIWhitespace(value[position]) || isComma(value[position])) {
position++
}
return position
}

func skipWhileASCIIWhitespace(value string, position int) int {
for position < len(value) && isASCIIWhitespace(value[position]) {
func skipWhileASCIIWhitespace(value string, position uint) uint {
for position < uint(len(value)) && isASCIIWhitespace(value[position]) {
position++
}
return position
}

func skipUntilASCIIWhitespace(value string, position int) int {
for position < len(value) && !isASCIIWhitespace(value[position]) {
func skipUntilASCIIWhitespace(value string, position uint) uint {
for position < uint(len(value)) && !isASCIIWhitespace(value[position]) {
position++
}
return position
Expand Down
Loading
0