changes to ffmpeg to stop having to put an escape

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

changes to ffmpeg to stop having to put an escape

Julian Gardner-2
A few weeks ago I had a problem with some eval code and it was pointed
out that i need to escape the ','.

So here is a small patch that needs passing on to the devel guys to have
a look at.

All this does is to ignore the fixed tokens when inside parenthesis, so
this works now

-filter_complex '[0:v] scale=160:90 [out], [v:0][out]
overlay=x=mod(10,2):y=20'

patch is here

diff --git a/libavutil/avstring.c b/libavutil/avstring.c
index 4c068f5..e19db8f 100644
--- a/libavutil/avstring.c
+++ b/libavutil/avstring.c
@@ -150,14 +150,26 @@ char *av_get_token(const char **buf, const char
*term)
  {
      char *out     = av_malloc(strlen(*buf) + 1);
      char *ret     = out, *end = out;
+    int   p_count = 0;
+
      const char *p = *buf;
      if (!out)
          return NULL;
      p += strspn(p, WHITESPACES);

-    while (*p && !strspn(p, term)) {
+    while (*p && (!strspn(p, term) || p_count)) {
          char c = *p++;
-        if (c == '\\' && *p) {
+        if (c == ')') {
+            if( p_count) {
+                p_count--;
+            }
+            *out++ = c;
+        }
+        else if (c == '(') {
+            p_count++;
+            *out++ = c;
+        }
+        else if (c == '\\' && *p) {
              *out++ = *p++;
              end    = out;
          } else if (c == '\'') {

--
BR

Joolz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: changes to ffmpeg to stop having to put an escape

Carl Eugen Hoyos-2
Am Mo., 16. Sept. 2019 um 22:41 Uhr schrieb Julian Gardner
<[hidden email]>:

>
> A few weeks ago I had a problem with some eval code and it was pointed
> out that i need to escape the ','.
>
> So here is a small patch that needs passing on to the devel guys to have
> a look at.
>
> All this does is to ignore the fixed tokens when inside parenthesis, so
> this works now
>
> -filter_complex '[0:v] scale=160:90 [out], [v:0][out]
> overlay=x=mod(10,2):y=20'
>
> patch is here

Patches are ignored on this mailing list, please merge "}" and
"else" and send your changes to the FFmpeg development
mailing list.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: changes to ffmpeg to stop having to put an escape

Nicolas George
In reply to this post by Julian Gardner-2
Julian Gardner (12019-09-16):
> A few weeks ago I had a problem with some eval code and it was pointed out
> that i need to escape the ','.
>
> So here is a small patch that needs passing on to the devel guys to have a
> look at.
>
> All this does is to ignore the fixed tokens when inside parenthesis, so this
> works now

This one works, and every other case involving parentheses becomes more
complex. Therefore it is not a good idea. It is possible to get rid of
the escaping, but it requires the parser to be aware of context. Small
fixes like that only make thing harder in the long run.

Regards,

--
  Nicolas George
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: changes to ffmpeg to stop having to put an escape

Julian Gardner-2

On 2019-09-17 11:42, Nicolas George wrote:

> Julian Gardner (12019-09-16):
>> A few weeks ago I had a problem with some eval code and it was pointed
>> out
>> that i need to escape the ','.
>>
>> So here is a small patch that needs passing on to the devel guys to
>> have a
>> look at.
>>
>> All this does is to ignore the fixed tokens when inside parenthesis,
>> so this
>> works now
>
> This one works, and every other case involving parentheses becomes more
> complex. Therefore it is not a good idea. It is possible to get rid of
> the escaping, but it requires the parser to be aware of context. Small
> fixes like that only make thing harder in the long run.
>
> Regards,

Can you show me a case where this will cause a failure as all my filters
work as they should.

Bear in mind this only fixes the cases where escaping is required inside
parenthesis.

---
BR

Joolz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: changes to ffmpeg to stop having to put an escape

Nicolas George
Julian Gardner (12019-09-17):
> Can you show me a case where this will cause a failure as all my filters
> work as they should.
>
> Bear in mind this only fixes the cases where escaping is required inside
> parenthesis.

It will fail everywhere parentheses are not supposed to be balanced.

Regards,

--
  Nicolas George

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: changes to ffmpeg to stop having to put an escape

Julian Gardner-2
On 2019-09-17 12:52, Nicolas George wrote:

> Julian Gardner (12019-09-17):
>> Can you show me a case where this will cause a failure as all my
>> filters
>> work as they should.
>>
>> Bear in mind this only fixes the cases where escaping is required
>> inside
>> parenthesis.
>
> It will fail everywhere parentheses are not supposed to be balanced.
>
> Regards,
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".

Not balanced, can you please give me an example so I can look into the
problem.

I can think of only one case and that would be someone using braces
inside a text field?

BR

Joolz


_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: changes to ffmpeg to stop having to put an escape

Nicolas George
Julian Gardner (12019-09-17):
> Not balanced, can you please give me an example so I can look into the
> problem.
>
> I can think of only one case and that would be someone using braces inside a
> text field?

Exactly. The function you are proposing to change is meant to parse
strings. Giving it a special case for parentheses is a maintenance and
user-experience nightmare.

Regards,

--
  Nicolas George

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: changes to ffmpeg to stop having to put an escape

Julian Gardner-2



On 2019-09-17 17:25, Nicolas George wrote:

> Julian Gardner (12019-09-17):
>> Not balanced, can you please give me an example so I can look into the
>> problem.
>>
>> I can think of only one case and that would be someone using braces
>> inside a
>> text field?
>
> Exactly. The function you are proposing to change is meant to parse
> strings. Giving it a special case for parentheses is a maintenance and
> user-experience nightmare.
>
> Regards,
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".

No its meant to parse anything, not just strings....


BR

Joolz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: changes to ffmpeg to stop having to put an escape

Nicolas George
Julian Gardner (12019-09-17):
> No its meant to parse anything, not just strings....

I assure you, it is meant to parse strings. The name of the file should
be a hint. It has been abused to parse anything, but it is meant for
strings. Fixing the problem with escaping needs to rework the problem
from the top, not from the bottom.

Regards,

--
  Nicolas George

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: changes to ffmpeg to stop having to put an escape

Julian Gardner-2
In reply to this post by Nicolas George
You mean like this



diff --git a/libavutil/avstring.c b/libavutil/avstring.c
index 4c068f5..8a264c0 100644
--- a/libavutil/avstring.c
+++ b/libavutil/avstring.c
@@ -150,14 +150,26 @@ char *av_get_token(const char **buf, const char
*term)
  {
      char *out     = av_malloc(strlen(*buf) + 1);
      char *ret     = out, *end = out;
+    int   p_count = 0;
+    int   speech  = 0;
+
      const char *p = *buf;
      if (!out)
          return NULL;
      p += strspn(p, WHITESPACES);

-    while (*p && !strspn(p, term)) {
+    while (*p && (!strspn(p, term) || p_count)) {
          char c = *p++;
-        if (c == '\\' && *p) {
+        if (c == 0x22) {
+            speech = !speech;
+            *out++ = c;
+        } else if (speech) {
+            *out++ = c;
+        } else if (c == ')') {
+            if( p_count) {
+                p_count--;
+            }
+            *out++ = c;
+        }
+        else if (c == '(') {
+            p_count++;
+            *out++ = c;
+        }
+        else if (c == '\\' && *p) {
              *out++ = *p++;
              end    = out;
          } else if (c == '\'') {

---
BR

Joolz


On 2019-09-17 17:25, Nicolas George wrote:

> Julian Gardner (12019-09-17):
>> Not balanced, can you please give me an example so I can look into the
>> problem.
>>
>> I can think of only one case and that would be someone using braces
>> inside a
>> text field?
>
> Exactly. The function you are proposing to change is meant to parse
> strings. Giving it a special case for parentheses is a maintenance and
> user-experience nightmare.
>
> Regards,
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: changes to ffmpeg to stop having to put an escape

Julian Gardner-2
In reply to this post by Nicolas George
On 2019-09-17 17:35, Nicolas George wrote:

> Julian Gardner (12019-09-17):
>> No its meant to parse anything, not just strings....
>
> I assure you, it is meant to parse strings. The name of the file should
> be a hint. It has been abused to parse anything, but it is meant for
> strings. Fixing the problem with escaping needs to rework the problem
> from the top, not from the bottom.
>
> Regards,
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".

and the name of the function should give you an idea av_get_token!!!!!

---
BR

Joolz


_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".