RandomNinjaAtk / arr-scripts

Extended Container Scripts - Automation scripts to make life easier!
GNU General Public License v3.0
678 stars 71 forks source link

[BUG] - *arr - arrUrlBase from /config/extended/functions Cannot Handle Multiple Backslashes #165

Closed zimmra closed 8 months ago

zimmra commented 8 months ago

Application Radarr or Sonarr

Host platform Docker on Ubuntu 23.10

Script /config/extended/functions

Script Version N/A (functions not versioned)

Describe the bug If you have an additional / in your UrlBase, nothing will work because the API cannot be verified. (Throws an error saying authentication header is missing) I have multiple sonarr and radarr instances, and do use the Base URL setting, so I use the following: /sonarr/hd /sonarr/4k /radarr/hd /radarr/4k

$arrUrlBase is incorrectly output as /sonarrhd, /sonarr4k, etc

To Reproduce Steps to reproduce the behavior:

  1. Go to Settings > General
  2. Set the URL Base setting to something with an additional / (e.g. /sonarr/hd)
  3. Try to set up the scripts
  4. See error

Expected behavior Expect the scripts to work

Additional context Manually modifying the functions to modify the sed command to only remove the first / successfully got the scripts working for me

This works for me:


-       arrUrlBase="/$(echo "$arrUrlBase" | sed "s/\///g")"
+       arrUrlBase="/$(echo "$arrUrlBase" | sed "s/\///")"
calebj commented 8 months ago

This change accidentally broke my lidarr setup. In verifyApiAccess, the URL evaluates to http://127.0.0.1:8686/lidarr//api/v1/system/status?apikey=xxx. When I add another expression to strip the trailing slash from the base

arrUrlBase="/$(echo "$arrUrlBase" | sed -e "s/\///" -e "s|/$||")"

and restart the services, it works again. I use a URL base of /lidarr to get everything behind one port using a reverse proxy.

Since the semantics of an empty path segment aren't a part of the standard, this technically isn't a lidarr bug. What I don't understand is why this issue doesn't affect @zimmra's use case, unless radarr and sonarr parse their URLs differently from lidarr. If this additional expression doesn't cause problems, I can submit a patch.

DeadPackets commented 4 months ago

Hi, this is still an issue. I have a URL base of /services/radarr and /services/sonarr and the plugins can never connect to the *arr instances.