mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 20:18:36 +00:00
Add additional Scrubber tests.
This commit is contained in:
@@ -77,6 +77,9 @@ public final class Scrubber {
|
||||
"\\b");
|
||||
private static final String IPV4_CENSOR = "...ipv4...";
|
||||
|
||||
private static final Pattern IPV6_PATTERN = Pattern.compile("([0-9a-fA-F]{0,4}:){3,7}([0-9a-fA-F]){0,4}");
|
||||
private static final String IPV6_CENSOR = "...ipv6...";
|
||||
|
||||
/**
|
||||
* The domain name except for TLD will be censored.
|
||||
*/
|
||||
@@ -104,6 +107,7 @@ public final class Scrubber {
|
||||
in = scrubUuids(in);
|
||||
in = scrubDomains(in);
|
||||
in = scrubIpv4(in);
|
||||
in = scrubIpv6(in);
|
||||
in = scrubCallLinkKeys(in);
|
||||
|
||||
return in;
|
||||
@@ -177,6 +181,12 @@ public final class Scrubber {
|
||||
(matcher, output) -> output.append(IPV4_CENSOR));
|
||||
}
|
||||
|
||||
private static CharSequence scrubIpv6(@NonNull CharSequence in) {
|
||||
return scrub(in,
|
||||
IPV6_PATTERN,
|
||||
(matcher, output) -> output.append(IPV6_CENSOR));
|
||||
}
|
||||
|
||||
private static CharSequence scrubCallLinkKeys(@NonNull CharSequence in) {
|
||||
return scrub(in,
|
||||
CALL_LINK_PATTERN,
|
||||
|
||||
@@ -125,7 +125,36 @@ public final class ScrubberTest {
|
||||
|
||||
{ "Not a Call Link Root Key (Missing Quartet) BCAF-FGHK-MNPQ-RSTX-ZRQH-BCDF-STXZ",
|
||||
"Not a Call Link Root Key (Missing Quartet) BCAF-FGHK-MNPQ-RSTX-ZRQH-BCDF-STXZ"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"2345:0425:2CA1:0000:0000:0567:5673:23b5",
|
||||
"...ipv6..."
|
||||
},
|
||||
|
||||
{ "2345:425:2CA1:0000:0000:567:5673:23b5",
|
||||
"...ipv6..." },
|
||||
|
||||
{ "2345:0425:2CA1:0:0:0567:5673:23b5",
|
||||
"...ipv6..." },
|
||||
|
||||
{ "2345:0425:2CA1::0567:5673:23b5",
|
||||
"...ipv6..." },
|
||||
|
||||
{ "FF01:0:0:0:0:0:0:1",
|
||||
"...ipv6..." },
|
||||
|
||||
{ "2001:db8::a3",
|
||||
"...ipv6..." },
|
||||
|
||||
{ "text before 2345:0425:2CA1:0000:0000:0567:5673:23b5 text after",
|
||||
"text before ...ipv6... text after" },
|
||||
|
||||
{ "Recipient::1",
|
||||
"Recipient::1" },
|
||||
|
||||
{ "Recipient::123",
|
||||
"Recipient::123" },
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user