Beginner Rust fag here, thoughts on my take on Jow Forums filter system?
gitlab.com
Trying to make a gtk3-based Jow Forums client for practice, need some feedback
No flamewars pls
Beginner Rust fag here, thoughts on my take on Jow Forums filter system?
gitlab.com
Trying to make a gtk3-based Jow Forums client for practice, need some feedback
No flamewars pls
cuck
[user0@primarypc ~]$ echo "cuck" | filter_rs
cuck
It's garbage because it's filtering anything beyond basic Latin characters without a reason. For example, it makes it impossible to use the General Punctation block (U+2000–U+206F) and any code sequences which allow you to triforce.
Also while getting notified of forbidden text might be useful, what's the purpose of applying word filters client-side?
>what's the purpose of applying word filters client-side?
Reducing captcha solving.
Also, this is mainly for a preview window :)
A few tips just from scanning over it:
- use &str instead of &String for most cases, the latter coerces into the former and it lets you pass string literals as well, unless you specifically want to get its allocated capacity or something
- you can trim strings using str::trim(), that'll take care of trimming leading/trailing whitespace
ty. I used String mainly because I am afraid of the lifetime hell.
So user, what color are your programming socks? Have you taken your HRT yet?
>ty. I used String mainly because I am afraid of the lifetime hell.
As a rule of thumb: Things which HAVE strings should use "String", things which USE strings should use "&str".
This
Also when the length of the string can be known at the compile time
>gtk3
Kill yourself discord tranny
>NOOOOOOOO YOU CAN'T JUST USE GTK IT HURTS MY FEELINGS
>t. gnome dev
for caring about "programming safety" you rustfags go out of your way to use shitty insecure gui libraries
Cuck
KEK
senpai.s becomes senpaitachi
nonbreakable space and a bunch of similar characters become breakable spaces
Incel
>filter list contains "back2reddit"
>code only checks single words
You might be better off doing something like this for checking filters:
for banned_word in SCREENED_KEYWORDS {
if arg.contains(banned_word) {
#[cfg(debug_assertions)]
{
println!("Keyword matches found: {}; keyword: {}", word, keyword);
}
return false;
}
}
Optionally you could keep the word splitting but add a var specifically for "back2reddit" that keeps track of progress while matching each word in the phrase:
// "back2reddit" progress counter
let mut btr_counter = 0;
for word in arg.split_ascii_whitespace() {
if word == "back" {
btr_counter = 1;
} else if word == "to" && btr_counter == 1 {
btr_counter = 2;
} else if word == "reddit" && btr_counter == 2 {
// full phrase found in order
return false;
} else {
btr_counter = 0;
}
}
Also fuck this spam filter.
4channel sanitize can take a &str instead of &String, can't it?
References implementing Deref get dereferenced when passed to other functions. Thus &String actually becomes &str.
It can, I should've updated it to take &str now
Apart from capitalised Cuck, it Jow Forums doesn't look for keywords in the middle of the word
AbKEKtbhsmhfam
Tbhtest
>gtk3
kys
Learn regex, retard.
yes, which is why you declare it with &str so it can take either. If the function definition is &String then you wouldn't be able to pass it a string literal
baka senpai desu KEK
wow it works (sorry new to g)
onions basedboy onions cuck baka desu senpai
f
▲
▲▲
▲
▲▲
܂܂ ▲
▲ ▲
Incredibly based.
...? how?
how did you manage backwards links?
܂ ▲
▲ ▲
based.