naughty_words 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5cf88a0fd1e82f3e4cecb2d6d768c15c71995cdf8897f728bd1a2d8436f52e7f
|
|
4
|
+
data.tar.gz: 8cfd6713a8c3a81c44994036df6208c8b92cdfc4c26a00d33e291b3ee302d376
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a5677af2c030e24321dd55d1d3931b18d57b0d5d85f2b349807fadf9520f1337de836b5e54ee514f012f65dbb388f096a16e73b8544c1300166bd1aeedfb7431
|
|
7
|
+
data.tar.gz: 6b2f7959635c02f2422e318acca920890756cd1bd4c1ed4dab3073813bb3ae8f57672d6e9b7da00eca3087b4f613342078f17bbb829a3b85ec0666b8b9d33990
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.0.2] - 2026-06-30
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- `filter` now respects file and DB allow lists, not just runtime overrides — a word in the allow list is no longer masked by `filter` even if it appears verbatim in a deny list
|
|
7
|
+
- `show_list(include_metadata: true)` no longer raises `NoMethodError` when ActiveRecord is not loaded
|
|
8
|
+
- Built-in word lists are now always loaded from file on first access; toggling `use_built_in_lists` off and back on no longer returns stale empty lists
|
|
9
|
+
- Migration template now uses `ActiveRecord::Migration.current_version` instead of a hardcoded `[7.0]`, fixing Rails 6/6.1 compatibility
|
|
10
|
+
|
|
3
11
|
## [0.1.0] - 2022-05-18
|
|
4
12
|
|
|
5
13
|
- Initial release
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
class CreateNaughtyWordsLists < ActiveRecord::Migration[
|
|
3
|
+
class CreateNaughtyWordsLists < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
|
|
4
4
|
def change
|
|
5
5
|
create_table :naughty_words_lists do |t|
|
|
6
6
|
t.string :word, null: false
|
data/lib/naughty_words/base.rb
CHANGED
|
@@ -29,7 +29,9 @@ module NaughtyWords
|
|
|
29
29
|
denied_words = Config.deny_overrides.dup
|
|
30
30
|
denied_words += deny_list_from_files if Config.use_built_in_lists
|
|
31
31
|
denied_words += deny_list_from_db
|
|
32
|
-
denied_words -= Config.allow_overrides
|
|
32
|
+
denied_words -= Config.allow_overrides
|
|
33
|
+
denied_words -= allow_list_from_files if Config.use_built_in_lists
|
|
34
|
+
denied_words -= allow_list_from_db
|
|
33
35
|
denied_words = denied_words.sort_by(&:length).reverse
|
|
34
36
|
|
|
35
37
|
denied_words.each do |word|
|
|
@@ -43,7 +45,7 @@ module NaughtyWords
|
|
|
43
45
|
def show_list(list:, include_metadata: false)
|
|
44
46
|
validate_list!(list)
|
|
45
47
|
|
|
46
|
-
if include_metadata && defined?(WordList)
|
|
48
|
+
if include_metadata && defined?(ActiveRecord::Base) && defined?(WordList)
|
|
47
49
|
WordList.where(list_type: list)
|
|
48
50
|
else
|
|
49
51
|
words = []
|
|
@@ -96,7 +98,6 @@ module NaughtyWords
|
|
|
96
98
|
end
|
|
97
99
|
|
|
98
100
|
def load_list(path)
|
|
99
|
-
return [] unless Config.use_built_in_lists
|
|
100
101
|
File.readlines(path, chomp: true).reject(&:empty?)
|
|
101
102
|
rescue Errno::ENOENT
|
|
102
103
|
raise Error, "List file not found: #{path}"
|
|
@@ -115,15 +116,6 @@ module NaughtyWords
|
|
|
115
116
|
str.downcase
|
|
116
117
|
end
|
|
117
118
|
|
|
118
|
-
def word_pattern(word)
|
|
119
|
-
escaped = Regexp.escape(word)
|
|
120
|
-
if Config.word_boundaries
|
|
121
|
-
/(?:^|[^a-zA-Z0-9])#{escaped}(?:$|[^a-zA-Z0-9])/i
|
|
122
|
-
else
|
|
123
|
-
/#{escaped}/i
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
|
|
127
119
|
def word_match?(string, word)
|
|
128
120
|
pattern = Config.word_boundaries ?
|
|
129
121
|
/(?:^|[^a-zA-Z0-9])#{Regexp.escape(word)}(?:$|[^a-zA-Z0-9])/i :
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: naughty_words
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Arnold
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-06-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|