util/text/validate.go: Safe is not safe

Labels: lifecycle/rotten

Timeline

3052 (3052) opened (edited)

https://github.com/git-bug/git-bug/blob/d499b6e9d3333334614924669b74640a2d0b5485/util/text/validate.go#L19-L34

doesn't check for invalid UTF-8, so this string would be returned as safe:

"\xA0\xA1"

also doesn't catch all control characters, so this would also be returned as safe:

"\u200E"

improved code:

package unicode

import (
   "unicode"
   "unicode/utf8"
)

func binary(src []byte) bool {
   for len(src) >= 1 {
      r, size := utf8.DecodeRune(src)
      if r == utf8.RuneError {
         if size == 1 {
            return true
         }
      }
      if unicode.Is(unicode.C, r) {
         return true
      }
      src = src[size:]
   }
   return false
}

github-actions (github-actions) commented

This bot triages untriaged issues and PRs according to the following rules:

  • After 90 days of inactivity, the lifecycle/stale label is applied
  • After 30 days of inactivity since lifecycle/stale was applied, the issue is closed

To remove the stale status, you can:

  • Remove the lifecycle/stale label
  • Comment on this issue

github-actions (github-actions) added label lifecycle/stale

github-actions (github-actions) commented

This bot triages issues in order to help the maintainers identify what needs attention, according to the following lifecycle rules:

  • After 90 days of inactivity, lifecycle/stale is applied
  • After 90 days of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied

This bot will not automatically close stale issues.

To remove the stale status, you can:

  • Remove the stale label from this issue
  • Comment on this issue
  • Close this issue
  • Offer to help out with triaging

To avoid automatic lifecycle management of this issue, add lifecycle/frozen.

github-actions (github-actions) added label lifecycle/rotten

github-actions (github-actions) removed label lifecycle/stale

3052 (3052) commented

!

sudoforge removed label lifecycle/dormant