Page 1 of 1

Sending nzb through api using api addurl results in bad nzbname

Posted: August 22nd, 2021, 5:26 am
by p0psicles
SABnzbd version: 3.1.1
Running on windows 10.'

I'm using Medusa in combination with Prowlarr.
Prowlarr functions as a newznab indexer. Medusa is getting an url back from prowlarr that downloads the nzb. Medusa sends the url using the Sabnzbd api "addurl" command.

Medusa has been doing this for many years. But only recently when we've added prowlarr support we've started noticing this issue.
The problem here is that the url returned by prowlarr is a valid url. When pasting it in the browser it will download the nzb for you.

This is the request that's being send to sab:

The nzb name is parsed as: `Zombie.Land.Saga.Revenge.S02E12.480p.x264-mSD.nzb; filename@=UTF-8''Zombie.Land.Saga.Revenge.S02E12.480p.x264-mSD.nzb`
Also the download is created with this name.

Let me know if you need more info.
The issue has been reported by a few Medusa users now. And it can be reproduced when using Medua + prowlarr + sabnzbd

Logs: https://gist.github.com/p0psicles/bd5d4 ... 1a88b92527

Re: Sending nzb through api using api addurl results in bad nzbname

Posted: August 22nd, 2021, 5:30 am
by p0psicles
I'd like to add some logs and the api request send to sab. But i'm a new user so I can't post links yet. I'll wait until I can update this post.

Re: Sending nzb through api using api addurl results in bad nzbname

Posted: August 23rd, 2021, 2:57 am
by safihre
I am not sure what is going on here, where it is adding this extra UTF-8 part.
Is this inside the headers or on the NZB file?
I'm not sure I want to setup the whole chain just to check if it's even SABnzbd's problem.. Is there any way I can test it somewhere?

Re: Sending nzb through api using api addurl results in bad nzbname

Posted: August 23rd, 2021, 6:02 am
by p0psicles
safihre wrote: August 23rd, 2021, 2:57 am Is this inside the headers or on the NZB file?
Sorry I don't understand that question. Or maybe I do? When I upload the NZB manual to sab it's Working fine. So I guess the headers?

I could try run sab on my dev machine in vscode. And get some debugging going on. Then we could do something like a teamviewer. That way you can step through it with the entire chain set up?

Re: Sending nzb through api using api addurl results in bad nzbname

Posted: August 23rd, 2021, 11:45 am
by jcfp
For the info inside the nzb, simply open the file in a text editor and check the metadata (typically near the very top). For the headers, download the nzb from that localhost port 9696 url with some util or browser that displays the http headers, such as the developer console/tool of common browsers (firefox, chromium).

Re: Sending nzb through api using api addurl results in bad nzbname

Posted: August 23rd, 2021, 12:02 pm
by p0psicles
I've tracked it down to the content-disposition header.
https://imgur.com/a/vQfMif1

value here is:

Code: Select all

attachment; filename=Zombie.Land.Saga.Revenge.S02E12.480p.x264-mSD.nzb; filename*=UTF-8''Zombie.Land.Saga.Revenge.S02E12.480p.x264-mSD.nzb
here:
https://github.com/sabnzbd/sabnzbd/blob ... er.py#L194
It will parse into:

Code: Select all

Zombie.Land.Saga.Revenge.S02E12.480p.x264-mSD.nzb; filename*=UTF-8''Zombie.Land.Saga.Revenge.S02E12.480p.x264-mSD.nzb
So now it's the discussion is prowlarr at fault, for returning that header. Or sabnzbd for parsing it this freely?

Personally I would use a regex for this. Something like:

Code: Select all

re.match(r'.*filename=([^=;]+)', value).group(1)
I can create a PR if you'd like?

Re: Sending nzb through api using api addurl results in bad nzbname

Posted: August 23rd, 2021, 2:07 pm
by safihre
Thanks for debugging!
It seems Prowlarr is doing things according to the RFC standard, and SABnzbd is wrong:
https://datatracker.ietf.org/doc/html/r ... tion-3.2.2

Re: Sending nzb through api using api addurl results in bad nzbname

Posted: August 24th, 2021, 5:50 am
by p0psicles
Is there something I can do?

Re: Sending nzb through api using api addurl results in bad nzbname

Posted: August 24th, 2021, 6:00 am
by safihre
No, I need to fix it!

Re: Sending nzb through api using api addurl results in bad nzbname

Posted: September 2nd, 2021, 6:03 am
by p0psicles
I see your going to do a release. Any chance this could get included? I could do a pr today. If you don't have time your self. I would like to provide a solution to my users.

Ow wait you already tagged.
I can still do the pr.

Re: Sending nzb through api using api addurl results in bad nzbname

Posted: September 7th, 2021, 3:00 am
by safihre
Sorry I forgot. Yes, can you indeed do a PR?
It should work for all these 3 cases:

Code: Select all

filename=Zombie.Land.Saga.Revenge.S02E12.480p.x264-mSD.nzb; filename*=UTF-8''Zombie.Land.Saga.Revenge.S02E12.480p.x264-mSD.nzb
filename=Zombie.Land.Saga.Revenge.S02E12.480p.x264-mSD.nzb;
filename*=UTF-8''Zombie.Land.Saga.Revenge.S02E12.480p.x264-mSD.nzb

Re: Sending nzb through api using api addurl results in bad nzbname

Posted: September 8th, 2021, 11:47 am
by p0psicles
done

Re: Sending nzb through api using api addurl results in bad nzbname

Posted: September 9th, 2021, 12:21 am
by p0psicles
Done.
The regex I used should support those three formats. I tested it icw Medusa+prowlarr, and that works