TrianguloY/UrlChecker

URL Cleaner: Custom redirection rule stops URLCheck from launching

Closed this issue · 3 comments

Steps to reproduce

I've edited the URL Cleaner module's rules as follows, which I believe satisfies the module's description of the config and is a valid ClearURLs rule (though I'm not sure how to verify that outside of URLCheck):

{
  "custom": {
    "jdoqocy": {
      "urlPattern": "^https?://(www\\.)?jdoqocy\\.com/",
      "redirections": ["[?&]URL=([^&]+)"]
    }
  },
  "providers": {
    /* default rules */
  }
}

(I've also had a few other goes at making the redirection rule stricter, including the full URL pattern again etc.)

Expected behavior

The rule should apply to e.g. https://www.jdoqocy.com/click-1234567-12345678?URL=https%3A%2F%2Fwww.example.com.

If the rule isn't valid for some reason, the UI should tell me (either at configuration time or link opening time) what's wrong.

Actual behavior

URLCheck gets stuck opening any link (spinning logo appears, but the main UI never opens).

If I go to edit the rules again, I note the forward slashes are now escaped at the JSON level -- that is, the URL pattern value has been changed to "^https?:\/\/(www\\.)?jdoqocy\\.com\/", where forward slashes do not need escaping? (If it's to escape within the regex, shouldn't there be two backslashes inserted instead, i.e. "^https?:\\/\\/(www\\.)?jdoqocy\\.com\\/"?)

I also note the existing rules escape their forward slashes with three backslashes? (That is, at the JSON layer, we end up with an escaped \ and an escaped /, the latter of which does not need escaping here.)

Nothing of interest appears to show up in logcat (seemingly just OS noise about views), no crash etc.

URLCheck version

2.13.1

Android version

Android 13

Android Custom/Specific ROM or Device

OnePlus Nord CE, stock ROM

Other details

May be related to #253, though I'm not sure if the crash there is the same "softlock" I'm seeing here or an actual Android crash?

Acknowledgements

  • I have searched the existing issues and this is a new ticket, NOT a duplicate or related to another open issue.
  • I have written a short but informative title.
  • I will fill out all of the requested information in this form.

Might have jumped the gun... tried taking the rule back out / resetting the module config but it was still failing to start up (from a lack of actual crash I'm not sure what the problem was) -- I've since wiped the app's data and now custom redirect rules seem to be working as expected.

Apologies, looks like this is working fine now. The backslash escaping is still a bit curious, but it works so I'll let it be. 🙂

I'm not sure what was causing the issue, did you tried disabling modules? If it happens again try that.

As for the escaping, that's due to how Json is encoded. The input is very basic, just a textview, and the content is directly encoded/decoded to a Json object. Characters need to be escaped. The forward slash doesn't need to be escaped, true, but the android implementation for some reason* does it.

*apparently that's to allow embedding the json in a script tag, which is useless here. I don't know if I can disable that...