[FFmpeg-devel] avformat/http: ignore the string after char '#'

Submitted by Steven Liu on Jan. 9, 2019, 6:24 a.m.

Details

Message ID 20190109062450.37901-1-lq@chinaffmpeg.org
State New
Headers show

Commit Message

Steven Liu Jan. 9, 2019, 6:24 a.m.
fix ticket: 7660
Because the char '#' is used for webbrowser to display, it won't present
in URI of http request.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/utils.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Nicolas George Jan. 9, 2019, 1:26 p.m.
Steven Liu (12019-01-09):
> fix ticket: 7660
> Because the char '#' is used for webbrowser to display, it won't present
> in URI of http request.
> 
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  libavformat/utils.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 7afef545fe..f93837a805 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -4731,6 +4731,7 @@ void av_url_split(char *proto, int proto_size,
>                    int *port_ptr, char *path, int path_size, const char *url)
>  {
>      const char *p, *ls, *ls2, *at, *at2, *col, *brk;
> +    char *bp;
>  
>      if (port_ptr)
>          *port_ptr = -1;
> @@ -4758,6 +4759,9 @@ void av_url_split(char *proto, int proto_size,
>      }
>  
>      /* separate path from hostname */
> +    bp = strchr(p, '#');
> +    if (bp)
> +        *bp = '\0';
>      ls = strchr(p, '/');
>      ls2 = strchr(p, '?');
>      if (!ls)

This invalid: p points either to url, which is const, or to NULL.

Also, I do not think the fix itself is correct: the fragment part should
not have arrived there in the first place.

Regards;
Steven Liu Jan. 10, 2019, 3:11 a.m.
> 在 2019年1月9日,下午9:26,Nicolas George <george@nsup.org> 写道:
> 
> Steven Liu (12019-01-09):
>> fix ticket: 7660
>> Because the char '#' is used for webbrowser to display, it won't present
>> in URI of http request.
>> 
>> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
>> ---
>> libavformat/utils.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>> 
>> diff --git a/libavformat/utils.c b/libavformat/utils.c
>> index 7afef545fe..f93837a805 100644
>> --- a/libavformat/utils.c
>> +++ b/libavformat/utils.c
>> @@ -4731,6 +4731,7 @@ void av_url_split(char *proto, int proto_size,
>>                   int *port_ptr, char *path, int path_size, const char *url)
>> {
>>     const char *p, *ls, *ls2, *at, *at2, *col, *brk;
>> +    char *bp;
>> 
>>     if (port_ptr)
>>         *port_ptr = -1;
>> @@ -4758,6 +4759,9 @@ void av_url_split(char *proto, int proto_size,
>>     }
>> 
>>     /* separate path from hostname */
>> +    bp = strchr(p, '#');
>> +    if (bp)
>> +        *bp = '\0';
>>     ls = strchr(p, '/');
>>     ls2 = strchr(p, '?');
>>     if (!ls)
> 
> This invalid: p points either to url, which is const, or to NULL.
> 
> Also, I do not think the fix itself is correct: the fragment part should
> not have arrived there in the first place.

Hi Nicolas,

    How should i understand the mean “the fragment part should not have arrived there in the first place.” ?

    When i use wget to get http://ffmpeg.org/helloworld/test#hello=24
    wget -dS http://ffmpeg.org/helloworld/test#hello=24
    the request is GET /helloworld/test

    But ffmpeg is use full URI “/helloworld/test#hello=24”
    That will forbidden by the http server in ticket: 7660.
     
    or just fix it in hls.c?


Thanks
Steven

> 
> Regards;
> 
> -- 
>  Nicolas George
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Nicolas George Jan. 10, 2019, 8:54 a.m.
Liu Steven (12019-01-10):
>     How should i understand the mean “the fragment part should not have arrived there in the first place.” ?
> 
>     When i use wget to get http://ffmpeg.org/helloworld/test#hello=24
>     wget -dS http://ffmpeg.org/helloworld/test#hello=24
>     the request is GET /helloworld/test
> 
>     But ffmpeg is use full URI “/helloworld/test#hello=24”
>     That will forbidden by the http server in ticket: 7660.
>      
>     or just fix it in hls.c?

I think the fragment part should be removed earlier. When the URL comes
directly from the user, I believe it should be the responsibility of the
user. When it comes from the application, the responsibility of the
application. And when it comes from a protocol, by the code handling
that protocol.

Your code just ignores the fragment, but the fragment information was
there for a reason in the first place, was it not?

Regards,
Steven Liu Jan. 10, 2019, 9:03 a.m.
> 在 2019年1月10日,下午4:54,Nicolas George <george@nsup.org> 写道:
> 
> Liu Steven (12019-01-10):
>>    How should i understand the mean “the fragment part should not have arrived there in the first place.” ?
>> 
>>    When i use wget to get http://ffmpeg.org/helloworld/test#hello=24
>>    wget -dS http://ffmpeg.org/helloworld/test#hello=24
>>    the request is GET /helloworld/test
>> 
>>    But ffmpeg is use full URI “/helloworld/test#hello=24”
>>    That will forbidden by the http server in ticket: 7660.
>> 
>>    or just fix it in hls.c?
> 
> I think the fragment part should be removed earlier. When the URL comes
> directly from the user, I believe it should be the responsibility of the
> user. When it comes from the application, the responsibility of the
> application. And when it comes from a protocol, by the code handling
> that protocol.
> 
> Your code just ignores the fragment, but the fragment information was
> there for a reason in the first place, was it not?

Ok, I get that mean, let me think how to fix that.

Thanks Nicolas, 

Steven
> 
> Regards,
> 
> -- 
>  Nicolas George
Nicolas George Jan. 10, 2019, 9:09 a.m.
Liu Steven (12019-01-10):
> Ok, I get that mean, let me think how to fix that.

Do you know why the fragment was there in the first place and what its
role was?

Regards,
Steven Liu Jan. 10, 2019, 9:14 a.m.
> 在 2019年1月10日,下午5:09,Nicolas George <george@nsup.org> 写道:
> 
> Liu Steven (12019-01-10):
>> Ok, I get that mean, let me think how to fix that.
> 
> Do you know why the fragment was there in the first place and what its
> role was?
I guess that is used for them web browser or player, i will ask that infomation from the ticket.


Thanks

Steven
> 
> Regards,
> 
> -- 
>  Nicolas George
Carl Eugen Hoyos Jan. 10, 2019, 5:10 p.m.
2019-01-10 10:14 GMT+01:00, Liu Steven <lq@chinaffmpeg.org>:
>
>
>> 在 2019年1月10日,下午5:09,Nicolas George <george@nsup.org> 写道:
>>
>> Liu Steven (12019-01-10):
>>> Ok, I get that mean, let me think how to fix that.
>>
>> Do you know why the fragment was there in the first place and what its
>> role was?
>
> I guess that is used for them web browser or player, i will ask that
> infomation from the ticket.

This may not necessarily help, maybe somebody here knows the answer?

Carl Eugen

Patch hide | download patch | download mbox

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 7afef545fe..f93837a805 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4731,6 +4731,7 @@  void av_url_split(char *proto, int proto_size,
                   int *port_ptr, char *path, int path_size, const char *url)
 {
     const char *p, *ls, *ls2, *at, *at2, *col, *brk;
+    char *bp;
 
     if (port_ptr)
         *port_ptr = -1;
@@ -4758,6 +4759,9 @@  void av_url_split(char *proto, int proto_size,
     }
 
     /* separate path from hostname */
+    bp = strchr(p, '#');
+    if (bp)
+        *bp = '\0';
     ls = strchr(p, '/');
     ls2 = strchr(p, '?');
     if (!ls)