Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
d0100c33
Commit
d0100c33
authored
Apr 06, 2006
by
Christophe Massiot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* modules/control/http/util.c: Simplify MRLParse, and fix parsing of quotes.
parent
e00360d9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
168 deletions
+55
-168
modules/control/http/util.c
modules/control/http/util.c
+55
-168
No files found.
modules/control/http/util.c
View file @
d0100c33
...
@@ -812,208 +812,95 @@ char *E_(FirstWord)( char *psz, char *new )
...
@@ -812,208 +812,95 @@ char *E_(FirstWord)( char *psz, char *new )
else
else
return
NULL
;
return
NULL
;
}
}
/**********************************************************************
/**********************************************************************
* Find_end_MRL: Find the end of the sentence :
* MRLParse: parse the MRL, find the MRL string and the options,
* this function parses the string psz and find the end of the item
* create an item with all information in it, and return the item.
* and/or option with detecting the " and ' problems.
* return NULL if there is an error.
* returns NULL if an error is detected, otherwise, returns a pointer
**********************************************************************/
* of the end of the sentence (after the last character)
**********************************************************************/
/* Function analog to FirstWord except that it relies on colon instead
static
char
*
Find_end_MRL
(
char
*
psz
)
* of space to delimit option boundaries. */
static
char
*
FirstOption
(
char
*
psz
,
char
*
new
)
{
{
char
*
s_sent
=
psz
;
vlc_bool_t
b_end
,
b_start
=
VLC_TRUE
;
switch
(
*
s_sent
)
while
(
*
psz
==
' '
)
{
psz
++
;
case
'\"'
:
{
s_sent
++
;
while
(
(
*
s_sent
!=
'\"'
)
&&
(
*
s_sent
!=
'\0'
)
)
while
(
*
psz
!=
'\0'
&&
(
*
psz
!=
' '
||
psz
[
1
]
!=
':'
)
)
{
if
(
*
s_sent
==
'\''
)
{
{
s_sent
=
Find_end_MRL
(
s_sent
);
if
(
*
psz
==
'\''
)
if
(
s_sent
==
NULL
)
{
{
return
NULL
;
char
c
=
*
psz
++
;
}
while
(
*
psz
!=
'\0'
&&
*
psz
!=
c
)
}
else
{
{
s_sent
++
;
if
(
*
psz
==
'\\'
&&
psz
[
1
]
!=
'\0'
)
psz
++
;
*
new
++
=
*
psz
++
;
b_start
=
VLC_FALSE
;
}
}
if
(
*
psz
==
c
)
psz
++
;
}
}
else
if
(
*
s_sent
==
'\"'
)
{
s_sent
++
;
return
s_sent
;
}
else
/* *s_sent == '\0' , which means the number of " is incorrect */
{
{
return
NULL
;
if
(
*
psz
==
'\\'
&&
psz
[
1
]
!=
'\0'
)
psz
++
;
*
new
++
=
*
psz
++
;
b_start
=
VLC_FALSE
;
}
}
break
;
}
}
case
'\''
:
b_end
=
!*
psz
;
{
s_sent
++
;
while
(
(
*
s_sent
!=
'\''
)
&&
(
*
s_sent
!=
'\0'
)
)
{
if
(
*
s_sent
==
'\"'
)
{
s_sent
=
Find_end_MRL
(
s_sent
);
if
(
s_sent
==
NULL
)
if
(
!
b_start
)
{
while
(
new
[
-
1
]
==
' '
)
return
NULL
;
new
--
;
}
}
else
{
s_sent
++
;
}
}
if
(
*
s_sent
==
'\''
)
*
new
++
=
'\0'
;
{
if
(
!
b_end
)
s_sent
++
;
return
psz
+
1
;
return
s_sent
;
else
}
else
/* *s_sent == '\0' , which means the number of ' is incorrect */
{
return
NULL
;
return
NULL
;
}
break
;
}
default:
/* now we can look for spaces */
{
while
(
(
*
s_sent
!=
' '
)
&&
(
*
s_sent
!=
'\0'
)
)
{
if
(
(
*
s_sent
==
'\''
)
||
(
*
s_sent
==
'\"'
)
)
{
s_sent
=
Find_end_MRL
(
s_sent
);
}
else
{
s_sent
++
;
}
}
return
s_sent
;
}
}
}
}
/**********************************************************************
* parse_MRL: parse the MRL, find the mrl string and the options,
playlist_item_t
*
E_
(
MRLParse
)(
intf_thread_t
*
p_intf
,
char
*
_psz
,
* create an item with all information in it, and return the item.
* return NULL if there is an error.
**********************************************************************/
playlist_item_t
*
E_
(
MRLParse
)(
intf_thread_t
*
p_intf
,
char
*
psz
,
char
*
psz_name
)
char
*
psz_name
)
{
{
char
**
ppsz_options
=
NULL
;
char
*
psz
=
strdup
(
_psz
);
char
*
mrl
;
char
*
s_mrl
=
psz
;
char
*
s_mrl
=
psz
;
int
i_error
=
0
;
char
*
s_temp
;
char
*
s_temp
;
int
i
=
0
;
int
i_options
=
0
;
playlist_item_t
*
p_item
=
NULL
;
playlist_item_t
*
p_item
=
NULL
;
/* In case there is spaces before the mrl */
while
(
*
s_mrl
==
' '
)
s_mrl
++
;
/* extract the mrl */
/* extract the mrl */
s_temp
=
strstr
(
s_mrl
,
" :"
);
s_temp
=
FirstOption
(
s_mrl
,
s_mrl
);
if
(
s_temp
==
NULL
)
if
(
s_temp
==
NULL
)
{
{
s_temp
=
s_mrl
+
strlen
(
s_mrl
);
s_temp
=
s_mrl
+
strlen
(
s_mrl
);
}
else
{
while
(
(
*
s_temp
==
' '
)
&&
(
s_temp
!=
s_mrl
)
)
{
s_temp
--
;
}
s_temp
++
;
}
/* if the mrl is between " or ', we must remove them */
if
(
(
*
s_mrl
==
'\''
)
||
(
*
s_mrl
==
'\"'
)
)
{
mrl
=
(
char
*
)
malloc
(
(
s_temp
-
s_mrl
-
1
)
*
sizeof
(
char
)
);
strncpy
(
mrl
,
(
s_mrl
+
1
)
,
s_temp
-
s_mrl
-
2
);
mrl
[
s_temp
-
s_mrl
-
2
]
=
'\0'
;
}
else
{
mrl
=
(
char
*
)
malloc
(
(
s_temp
-
s_mrl
+
1
)
*
sizeof
(
char
)
);
strncpy
(
mrl
,
s_mrl
,
s_temp
-
s_mrl
);
mrl
[
s_temp
-
s_mrl
]
=
'\0'
;
}
}
p_item
=
playlist_ItemNew
(
p_intf
,
s_mrl
,
psz_name
);
s_mrl
=
s_temp
;
s_mrl
=
s_temp
;
/* now we can take care of the options */
/* now we can take care of the options */
while
(
(
*
s_mrl
!=
'\0'
)
&&
(
i_error
==
0
)
)
while
(
*
s_mrl
!=
'\0'
)
{
{
switch
(
*
s_mrl
)
s_temp
=
FirstOption
(
s_mrl
,
s_mrl
);
{
if
(
s_mrl
==
'\0'
)
case
' '
:
{
s_mrl
++
;
break
;
break
;
}
case
':'
:
/* an option */
{
s_temp
=
Find_end_MRL
(
s_mrl
);
if
(
s_temp
==
NULL
)
if
(
s_temp
==
NULL
)
{
{
i_error
=
1
;
s_temp
=
s_mrl
+
strlen
(
s_mrl
)
;
}
}
else
playlist_ItemAddOption
(
p_item
,
s_mrl
);
{
i_options
++
;
ppsz_options
=
realloc
(
ppsz_options
,
i_options
*
sizeof
(
char
*
)
);
ppsz_options
[
i_options
-
1
]
=
malloc
(
(
s_temp
-
s_mrl
+
1
)
*
sizeof
(
char
)
);
strncpy
(
ppsz_options
[
i_options
-
1
]
,
s_mrl
,
s_temp
-
s_mrl
);
/* don't forget to finish the string with a '\0' */
(
ppsz_options
[
i_options
-
1
])[
s_temp
-
s_mrl
]
=
'\0'
;
s_mrl
=
s_temp
;
s_mrl
=
s_temp
;
}
}
break
;
}
default:
{
i_error
=
1
;
break
;
}
}
}
if
(
i_error
!=
0
)
free
(
psz
);
{
free
(
mrl
);
}
else
{
/* now create an item */
p_item
=
playlist_ItemNew
(
p_intf
,
mrl
,
psz_name
);
for
(
i
=
0
;
i
<
i_options
;
i
++
)
{
playlist_ItemAddOption
(
p_item
,
ppsz_options
[
i
]
);
}
}
for
(
i
=
0
;
i
<
i_options
;
i
++
)
free
(
ppsz_options
[
i
]
);
if
(
i_options
)
free
(
ppsz_options
);
return
p_item
;
return
p_item
;
}
}
/**********************************************************************
/**********************************************************************
* RealPath: parse ../, ~ and path stuff
* RealPath: parse ../, ~ and path stuff
**********************************************************************/
**********************************************************************/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment