Malformed subdomain regex prevents local users from posting
Environment
- Installation type (OTP or From Source): From source
- Pleroma version (could be found in the "Version" tab of settings in Pleroma-FE): 2.6.1
- Elixir version (
elixir -v
for from source installations, N/A for OTP): Elixir 1.13.4 (compiled with Erlang/OTP 25) - Operating system: Ubuntu 20.04.4 LTS
- PostgreSQL version (
psql -V
): 12.17
Bug description
Entering a malformed subdomain regex into the 'reject' list of MRF simple causes the classic "error: e.text is undefined" when making a post, though this error doesn't to go away after a bit like it normally does. Making replies to existing remote posts seem to be unaffected.
Feb 17 09:11:26 pl-vm-app-00 mix[1486949]: 09:11:26.995 request_id=F7SbdVirHdQbkTkAABtB [error] Internal server error: %Regex.CompileError{message: "nothing to repeat at position 1"}
Feb 17 09:11:26 pl-vm-app-00 mix[1486949]: 09:11:26.996 [error] #PID<0.2752.0> running Pleroma.Web.Endpoint (connection #PID<0.2751.0>, stream id 1) terminated
Feb 17 09:11:26 pl-vm-app-00 mix[1486949]: Server: pl.valkyrie.world:80 (http)
Feb 17 09:11:26 pl-vm-app-00 mix[1486949]: Request: POST /api/v1/statuses
Feb 17 09:11:26 pl-vm-app-00 mix[1486949]: ** (exit) an exception was raised:
Feb 17 09:11:26 pl-vm-app-00 mix[1486949]: ** (Regex.CompileError) nothing to repeat at position 1
Feb 17 09:11:26 pl-vm-app-00 mix[1486949]: (elixir 1.13.4) lib/regex.ex:220: Regex.compile!/2
Feb 17 09:11:26 pl-vm-app-00 mix[1486949]: (pleroma 2.6.1) lib/pleroma/web/activity_pub/mrf.ex:140: anonymous fn/2 in Pleroma.Web.ActivityPub.MRF.subdomains_regex/1
Feb 17 09:11:26 pl-vm-app-00 mix[1486949]: (elixir 1.13.4) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
Feb 17 09:11:26 pl-vm-app-00 mix[1486949]: (pleroma 2.6.1) lib/pleroma/web/activity_pub/mrf.ex:140: Pleroma.Web.ActivityPub.MRF.subdomains_regex/1
Feb 17 09:11:26 pl-vm-app-00 mix[1486949]: (pleroma 2.6.1) lib/pleroma/web/activity_pub/mrf/simple_policy.ex:32: Pleroma.Web.ActivityPub.MRF.SimplePolicy.check_reject/2
Feb 17 09:11:26 pl-vm-app-00 mix[1486949]: (pleroma 2.6.1) lib/pleroma/web/activity_pub/mrf/simple_policy.ex:214: Pleroma.Web.ActivityPub.MRF.SimplePolicy.filter/1
Feb 17 09:11:26 pl-vm-app-00 mix[1486949]: (elixir 1.13.4) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
Feb 17 09:11:26 pl-vm-app-00 mix[1486949]: (pleroma 2.6.1) lib/pleroma/web/activity_pub/activity_pub.ex:130: Pleroma.Web.ActivityPub.ActivityPub.insert/4
I had this occur when forgetting to enter a '.' after a '*' character in the MRF's reject list. For example: *spam.me
instead of *.spam.me
. Thankfully, correcting the regex resolved the bug. I don't know if the current implementation of MRF would allow validation of these regex when submitting in the admin FE, but it would certainly go a long way to preventing this bug.