Skip to content

Commit

Permalink
Merge pull request #11 from anuraaga/no-containsrune
Browse files Browse the repository at this point in the history
Replace ContainsRune with IndexByte
  • Loading branch information
anuraaga authored Sep 14, 2022
2 parents 05a6004 + 158c7f4 commit 6011d4d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions sqli.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func (s *sqliState) fold() int {
case s.tokenVec[left].category == sqliTokenTypeCollate && s.tokenVec[left+1].category == sqliTokenTypeBareWord:
// there are too many collation types.. so if the bareword has a "_"
// then it's TYPE_SQLTYPE
if strings.ContainsRune(s.tokenVec[left+1].val[:], '_') {
if strings.IndexByte(s.tokenVec[left+1].val[:], '_') != -1 {
s.tokenVec[left+1].category = sqliTokenTypeSQLType
left = 0
}
Expand Down Expand Up @@ -864,7 +864,7 @@ func (s *sqliState) check() bool {
// if input has a single quote, then
// test as if input was actually '
// example: if input if "1' = 1", then pretend it's "'1' = 1"
if strings.ContainsRune(s.input, rune(byteSingle)) {
if strings.IndexByte(s.input, byteSingle) != -1 {
s.sqliFingerprint(sqliFlagQuoteSingle | sqliFlagSQLAnsi)
if s.lookupWord(sqliLookupFingerprint, s.fingerprint) != byteNull {
return true
Expand All @@ -877,7 +877,7 @@ func (s *sqliState) check() bool {
}

// same as above but with a double quote
if strings.ContainsRune(s.input, rune(byteDouble)) {
if strings.IndexByte(s.input, byteDouble) != -1 {
s.sqliFingerprint(sqliFlagQuoteDouble | sqliFlagSQLMysql)
if s.lookupWord(sqliLookupFingerprint, s.fingerprint) != byteNull {
return true
Expand Down
4 changes: 2 additions & 2 deletions sqli_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func flag2Delimiter(flag int) byte {
// " \\" " two backslash = not escaped!
// " \\\" " three backslash = escaped!
func isBackslashEscaped(str string) bool {
if !strings.ContainsRune(str, '\\') {
if strings.IndexByte(str, '\\') == -1 {
return false
}

Expand Down Expand Up @@ -58,7 +58,7 @@ func isByteWhite(ch byte) bool {
// regexp.match(str, "[ABC]*")
func strLenSpn(s string, length int, accept string) int {
for i := 0; i < length; i++ {
if !strings.ContainsRune(accept, rune(s[i])) {
if strings.IndexByte(accept, s[i]) == -1 {
return i
}
}
Expand Down

0 comments on commit 6011d4d

Please sign in to comment.