Bazarr: [Bug] String sanitation can cause unexpected behaviour in the 'Post-processing command' field

Created on 14 Feb 2019  路  12Comments  路  Source: morpheus65535/bazarr

Summary

The Settings->Post-processing command field looses double/single quotation marks if they're the first and/or last char inserted in the field, after saving. This can cause problems when, for example the last word in the field is the {{episode}} or {{episode_name}} variable which might have spaces/special characters inside and need to be quoted to be properly passed to the command.

Use case where encountered

I watch series directly on my LG tv (through dlna). The TV can only detect subtitles if they have the exactly same name as the video file and are in the same directory. Bazarr already copies the exact episode/movie file name with the addition of the {{subtitles_language_code2}} variable prepended to the subtitle file extension, for that reason I'm using something like:
rename.py "{{subtitles}}" "{{subtitles_language_code2}}" 2>&1
to get rid of the language code.

Reproduction

Input any string in the Post-processing field starting and/or ending with quotes, hit Save, and check that the value in field is missing them.

Root cause

This .strip sanitation:
https://github.com/morpheus65535/bazarr/blob/11ff3b33287efcde1691950048c0e31123d63a1b/libs/simpleconfigparser/__init__.py#L131

Software

Current Bazarr master branch (latest affected released version as of writing - v0.7.1)

Comment/Rationale

The simpleconfigparser is used for other fields as well, so the sanitation in question might be needed, but in the case with the command field, it is a rather nasty little bugger that can be tricky to understand, if you do not dig in.

bug wontfix

Most helpful comment

pls dont remove post processing ,I use it!! :)

All 12 comments

You can simply enable single language in settings... This setting can do that for you

I did not know that... Thanks.
The single language setting will prevent the bug from being observable in a use case like mine (although I am using multiple languages for subtitles), it will not fix it for other possible cases.

Post processing is like the most unloved feature in Bazarr. We haven't work on it since almost a year. I'm not even sure it is really used. I keep thinking about dropping it for that reason.

Well, removing the post processing functionality will fix the issue, in a sense.
Whatever the decision, keep up the good work.

Anything I can do to help with this ?

No, nothing else than testing when I鈥檓 going to have this fixed ;-)

pls dont remove post processing ,I use it!! :)

Hi, please don't remove it!
I also use it (to sync whatever english subtitle using machine learning).

I encountered this bug (quote disappearing at the end) and resolved it by using this syntax (appending a "foo" var to not have a quote by the end of the line):
/opt/config/bazarr/config/Bazarr-Post-Processing.sh '{{subtitles}}' '{{episode}}' foo

If I want to fix this, I have to migrate to some other config file provider as simpleconfigparser strip the quotes from the beginning and the end and there's no option to disable that.

If I want to fix this, I have to migrate to some other config file provider as simpleconfigparser strip the quotes from the beginning and the end and there's no option to disable that.

Fixes for this are easy to implement, as mentioned in previous comments, so I totally agree with you.

No problem for me either.
Just don't remove the post-processing option please ;-)

Sorry mate, I didn't see this thread before posting.

Perhaps a disclaimer/tooltip/hint/link in the gui would help prevent more people opening up tickets for this.

Was this page helpful?
0 / 5 - 0 ratings