confidential_info_redactor_lite 0.0.26 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ceeb1140b59f594ab6600ed27b362721f7626cb
|
4
|
+
data.tar.gz: b8daee381620d1fdd3e3883c1ea9d0702ceb2c6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c8dbb77b0779043b8fcdc501730624f7827d0e54d1a81cdaaf33e677ef9b2242854c323b0eeb535eb97096cb0e97a3a225ab2642058de2f24c36ac473c983dc
|
7
|
+
data.tar.gz: 6b426392130a87db3b65a320a74f77911f2db7491e80f7becf793d216f9a5d538ad76a41c79980e389285d10fa74ee383ba5fb9f381a4f14f5cc29b80a3f5411
|
@@ -88,10 +88,14 @@ module ConfidentialInfoRedactorLite
|
|
88
88
|
|
89
89
|
def redact_hyperlinks_html(txt)
|
90
90
|
redacted_text = redact_hyperlinks(txt).gsub(/\>\s#{Regexp.escape(token_text)}\s\</, ">#{token_text}<").gsub(/\>\s#{Regexp.escape(number_text)}\s\</, ">#{number_text}<").gsub(/\>\s#{Regexp.escape(date_text)}\s\</, ">#{date_text}<").gsub(/\>\s#{Regexp.escape(email_text)}\s\</, ">#{email_text}<").gsub(/\>\s#{Regexp.escape(hyperlink_text)}\s\</, ">#{hyperlink_text}<")
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
91
|
+
if language.eql?('ja')
|
92
|
+
final_hyperlinks_tokens = txt.scan(/http[a-zA-Z\/\:\.\-]+|www[a-zA-Z\/\:\.\-]+/)
|
93
|
+
else
|
94
|
+
original_sentence_array = txt.split(' ')
|
95
|
+
redacted_sentence_array = redacted_text.split(' ')
|
96
|
+
diff = original_sentence_array - redacted_sentence_array
|
97
|
+
final_hyperlinks_tokens = diff.map { |token| token[-1].eql?('.') ? token[0...-1] : token }.map { |token| token[-1].eql?(')') ? token[0...-1] : token }.map { |token| token[0].eql?('(') ? token[1..token.length] : token }
|
98
|
+
end
|
95
99
|
[redacted_text.gsub(/(?<=[^\>])#{Regexp.escape(hyperlink_text)}/, "<span class='confidentialHyperlinks'>#{hyperlink_text}</span>"), final_hyperlinks_tokens]
|
96
100
|
end
|
97
101
|
|
@@ -239,6 +239,11 @@ RSpec.describe ConfidentialInfoRedactorLite::Redactor do
|
|
239
239
|
text = 'My Transformation - avoid Trans.'
|
240
240
|
expect(described_class.new(text: text, language: 'en', tokens: tokens, number_text: '**redacted number**', date_text: '^^redacted date^^', token_text: '*****', hyperlink_text: '*****', email_text: '*****', dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr).redact).to eq('My Transformation - avoid *****.')
|
241
241
|
end
|
242
|
+
|
243
|
+
it 'redacts all confidential information from a text #007' do
|
244
|
+
text = 'これはjohn@gmail.comかk.light@tuv.eu.usかhttps://www.tm-town.comです.'
|
245
|
+
expect(described_class.new(text: text, language: 'ja', tokens: nil, number_text: '**redacted number**', date_text: '^^redacted date^^', token_text: '*****', hyperlink_text: '*****', email_text: '*****', dow: en_dow, dow_abbr: en_dow_abbr, months: en_months, months_abbr: en_month_abbr).hyperlinks_html[1]).to eq(["https://www.tm-town.com"])
|
246
|
+
end
|
242
247
|
end
|
243
248
|
|
244
249
|
describe '#redact_html' do
|