Skip to content

bug: panic, when using utf-8 #47

@IAD

Description

@IAD

Describe the bug

use the test:

func TestDefaultDriver_UTF8(t *testing.T) {
	detector := goaway.NewProfanityDetector().WithCustomDictionary(
		[]string{"anal", "あほ"}, // profanities
		[]string{"あほほ"},        // falsePositives
		[]string{"あほほし"},       // falseNegatives
	)

	message := "いい加減にしろ あほほし あほほ あほ anal ほ"
	expected := "いい加減にしろ **** あほほ ** **** ほ"

	isProfane := detector.IsProfane(message)
	require.True(t, isProfane)

	censored := detector.Censor(message)
	require.Equal(t, expected, censored)
}

What do you see?

panic at:
github.com/TwiN/go-away.(*ProfanityDetector).Censor(0xc000082f08, {0xf8f7c7, 0x3c})
.../github.com/TwiN/go-away/goaway.go:193 +0x7a5

What do you expect to see?

UTF-8 filtered as well as ASCII

List the steps that must be taken to reproduce this issue

use the test from the description

Version

v1.6.9

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions