diff options
| author | 2024-03-11 09:53:20 +0100 | |
|---|---|---|
| committer | 2024-03-11 09:53:20 +0100 | |
| commit | 48941cfeaf2205b3159c727c8edeece846457efb (patch) | |
| tree | 46a9edee03023204ab0c3e28ea41207d642f4dff /data.c | |
| parent | Also accept Article objects. (diff) | |
| download | snac2-48941cfeaf2205b3159c727c8edeece846457efb.tar.gz snac2-48941cfeaf2205b3159c727c8edeece846457efb.tar.xz snac2-48941cfeaf2205b3159c727c8edeece846457efb.zip | |
Also call content_check() from timeline_request().
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 4 |
1 files changed, 3 insertions, 1 deletions
| @@ -2010,7 +2010,8 @@ int instance_unblock(const char *instance) | |||
| 2010 | /** content filtering **/ | 2010 | /** content filtering **/ |
| 2011 | 2011 | ||
| 2012 | int content_check(const char *file, const xs_dict *msg) | 2012 | int content_check(const char *file, const xs_dict *msg) |
| 2013 | /* checks if message content matches any of the regexes in file */ | 2013 | /* checks if a message's content matches any of the regexes in file */ |
| 2014 | /* file format: one regex per line */ | ||
| 2014 | { | 2015 | { |
| 2015 | xs *fn = xs_fmt("%s/%s", srv_basedir, file); | 2016 | xs *fn = xs_fmt("%s/%s", srv_basedir, file); |
| 2016 | FILE *f; | 2017 | FILE *f; |
| @@ -2021,6 +2022,7 @@ int content_check(const char *file, const xs_dict *msg) | |||
| 2021 | if ((f = fopen(fn, "r")) != NULL) { | 2022 | if ((f = fopen(fn, "r")) != NULL) { |
| 2022 | srv_debug(1, xs_fmt("content_check: loading regexes from %s", fn)); | 2023 | srv_debug(1, xs_fmt("content_check: loading regexes from %s", fn)); |
| 2023 | 2024 | ||
| 2025 | /* massage content (strip HTML tags, etc.) */ | ||
| 2024 | xs *c = xs_regex_replace(v, "<[^>]+>", " "); | 2026 | xs *c = xs_regex_replace(v, "<[^>]+>", " "); |
| 2025 | c = xs_regex_replace_i(c, " {2,}", " "); | 2027 | c = xs_regex_replace_i(c, " {2,}", " "); |
| 2026 | c = xs_tolower_i(c); | 2028 | c = xs_tolower_i(c); |