mirror of
https://github.com/kkroening/ffmpeg-python.git
synced 2025-04-06 04:15:44 +08:00
escape "[]=;:," characters in filter arguments to avoid early termination
This commit is contained in:
parent
a986cbe9fb
commit
efc0104ae4
@ -1,6 +1,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from builtins import object
|
from builtins import object
|
||||||
|
from past.builtins import basestring
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
|
|
||||||
@ -51,8 +52,21 @@ class FilterNode(Node):
|
|||||||
"""FilterNode"""
|
"""FilterNode"""
|
||||||
def _get_filter(self):
|
def _get_filter(self):
|
||||||
params_text = self._name
|
params_text = self._name
|
||||||
arg_params = ['{}'.format(arg) for arg in self._args]
|
|
||||||
kwarg_params = ['{}={}'.format(k, self._kwargs[k]) for k in sorted(self._kwargs)]
|
# Helper function to escape uncomfortable characters
|
||||||
|
def escape_chars(seq, keys):
|
||||||
|
for k in keys:
|
||||||
|
if not isinstance(seq[k], basestring):
|
||||||
|
continue
|
||||||
|
for ch in "[]=;:,":
|
||||||
|
seq[k] = seq[k].replace(ch, "\\\\"+ch)
|
||||||
|
return seq
|
||||||
|
|
||||||
|
_args = escape_chars(self._args[:], range(len(self._args)))
|
||||||
|
_kwargs = escape_chars(self._kwargs.copy(), self._kwargs.keys())
|
||||||
|
|
||||||
|
arg_params = ['{}'.format(arg) for arg in _args]
|
||||||
|
kwarg_params = ['{}={}'.format(k, _kwargs[k]) for k in sorted(_kwargs)]
|
||||||
params = arg_params + kwarg_params
|
params = arg_params + kwarg_params
|
||||||
if params:
|
if params:
|
||||||
params_text += '={}'.format(':'.join(params))
|
params_text += '={}'.format(':'.join(params))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user