Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: incorrect position replaced #46

Open
IAD opened this issue Jan 16, 2023 · 0 comments
Open

bug: incorrect position replaced #46

IAD opened this issue Jan 16, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@IAD
Copy link

IAD commented Jan 16, 2023

Describe the bug

version: 1.6.9
test:


import (
	"testing"

	goaway "github.com/TwiN/go-away"
	"github.com/stretchr/testify/require"
)

func TestDefaultDriver_AR_4768(t *testing.T) {
	detector := goaway.NewProfanityDetector().WithCustomDictionary(
		[]string{"anal", "babi"}, // profanities
		[]string{"babibu"},       // falsePositives
		[]string{"babibube"},     // falseNegatives
	)

	message := "message with old anal new babi falsePositive babibu falseNegative babibube"
	expected := "message with old **** new **** falsePositive babibu falseNegative ********"

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

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

	/*
		Original :message with old anal new babi falsePositive babibu falseNegative babibube
		Expected :message with old **** new **** falsePositive babibu falseNegative ********
		Actual   :message with old anal ne* ***i fa****ositive babibu falseNegative ********
	*/
}

What do you see?

message with old **** new **** falsePositive babibu falseNegative ********

What do you expect to see?

message with old **** new **** falsePositive babibu falseNegative ********

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

@IAD IAD added the bug Something isn't working label Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant