diff options
author | albeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-01-10 14:38:07 +0000 |
---|---|---|
committer | albeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-01-10 14:38:07 +0000 |
commit | a546b9abc048df35df75741a2cf6c9fb3d31c478 (patch) | |
tree | 462787dcbef2168fc9884d0d4de22181a0dd2ee5 | |
parent | 05a7f113231e191bc81faf104457afafc13342a0 (diff) | |
download | mpv-a546b9abc048df35df75741a2cf6c9fb3d31c478.tar.bz2 mpv-a546b9abc048df35df75741a2cf6c9fb3d31c478.tar.xz |
Fix long standing bug where last (and sometimes first) char of the
hostname got ripped.
Also fix url unescaping with hex A ... F
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@11772 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | libmpdemux/url.c | 14 | ||||
-rw-r--r-- | m_option.c | 11 |
2 files changed, 15 insertions, 10 deletions
diff --git a/libmpdemux/url.c b/libmpdemux/url.c index c24f4dee45..6db6c48dab 100644 --- a/libmpdemux/url.c +++ b/libmpdemux/url.c @@ -14,9 +14,9 @@ URL_t* url_new(const char* url) { - int pos1, pos2; + int pos1, pos2,v6addr = 0; URL_t* Curl; - char *ptr1=NULL, *ptr2=NULL, *ptr3=NULL; + char *ptr1=NULL, *ptr2=NULL, *ptr3=NULL, *ptr4=NULL; int jumpSize = 3; if( url==NULL ) return NULL; @@ -106,11 +106,13 @@ url_new(const char* url) { // in IPv6 URL the numeric address should be inside square braces. ptr2 = strstr(ptr1, "["); ptr3 = strstr(ptr1, "]"); - if( ptr2!=NULL && ptr3!=NULL ) { + ptr4 = strstr(ptr1, "/"); + if( ptr2!=NULL && ptr3!=NULL && ptr2 < ptr3 && (!ptr4 || ptr4 > ptr3)) { // we have an IPv6 numeric address ptr1++; pos1++; ptr2 = ptr3; + v6addr = 1; } else { ptr2 = ptr1; @@ -138,7 +140,7 @@ url_new(const char* url) { Curl->port = atoi(ptr2+1); pos2 = ptr2-url; } - if( strstr(ptr1, "]")!=NULL ) pos2--; + if( v6addr ) pos2--; // copy the hostname in the URL container Curl->hostname = (char*)malloc(pos2-pos1+1); if( Curl->hostname==NULL ) { @@ -206,9 +208,9 @@ url_unescape_string(char *outbuf, const char *inbuf) if ( ((c1>='0' && c1<='9') || (c1>='A' && c1<='F')) && ((c2>='0' && c2<='9') || (c2>='A' && c2<='F')) ) { if (c1>='0' && c1<='9') c1-='0'; - else c1-='A'; + else c1-='A'-10; if (c2>='0' && c2<='9') c2-='0'; - else c2-='A'; + else c2-='A'-10; c = (c1<<4) + c2; } } diff --git a/m_option.c b/m_option.c index 252d924100..3be937f76b 100644 --- a/m_option.c +++ b/m_option.c @@ -1595,8 +1595,8 @@ m_option_type_t m_option_type_obj_presets = { static int parse_custom_url(m_option_t* opt,char *name, char *url, void* dst, int src) { - int pos1, pos2, r; - char *ptr1=NULL, *ptr2=NULL, *ptr3=NULL; + int pos1, pos2, r, v6addr = 0; + char *ptr1=NULL, *ptr2=NULL, *ptr3=NULL, *ptr4=NULL; m_struct_t* desc = opt->priv; if(!desc) { @@ -1688,11 +1688,14 @@ static int parse_custom_url(m_option_t* opt,char *name, // in an IPv6 URL the numeric address should be inside square braces. ptr2 = strstr(ptr1, "["); ptr3 = strstr(ptr1, "]"); - if( ptr2!=NULL && ptr3!=NULL ) { + // If the [] is after the first it isn't the hostname + ptr4 = strstr(ptr1, "/"); + if( ptr2!=NULL && ptr3!=NULL && (ptr2 < ptr3) && (!ptr4 || ptr4 > ptr3)) { // we have an IPv6 numeric address ptr1++; pos1++; ptr2 = ptr3; + v6addr = 1; } else { ptr2 = ptr1; } @@ -1733,7 +1736,7 @@ static int parse_custom_url(m_option_t* opt,char *name, } pos2 = ptr2-url; } - if( strstr(ptr1, "]")!=NULL ) pos2--; + if( v6addr ) pos2--; // Get the hostname if(pos2-pos1 > 0) { if(!m_option_list_find(desc->fields,"hostname")) { |