Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
07262663
Commit
07262663
authored
Sep 07, 2008
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve subsdec html output robustness.
parent
e422319d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
44 deletions
+63
-44
modules/codec/subtitles/subsdec.c
modules/codec/subtitles/subsdec.c
+63
-44
No files found.
modules/codec/subtitles/subsdec.c
View file @
07262663
...
...
@@ -576,6 +576,25 @@ static char *StripTags( char *psz_subtitle )
* returned, and the rendering engine will fall back to the
* plain text version of the subtitle.
*/
static
void
HtmlNPut
(
char
**
ppsz_html
,
const
char
*
psz_text
,
int
i_max
)
{
const
int
i_len
=
strlen
(
psz_text
);
strncpy
(
*
ppsz_html
,
psz_text
,
i_max
);
*
ppsz_html
+=
__MIN
(
i_max
,
i_len
);
}
static
void
HtmlPut
(
char
**
ppsz_html
,
const
char
*
psz_text
)
{
strcpy
(
*
ppsz_html
,
psz_text
);
*
ppsz_html
+=
strlen
(
psz_text
);
}
static
void
HtmlCopy
(
char
**
ppsz_html
,
char
**
ppsz_subtitle
,
const
char
*
psz_text
)
{
HtmlPut
(
ppsz_html
,
psz_text
);
*
ppsz_subtitle
+=
strlen
(
psz_text
);
}
static
char
*
CreateHtmlSubtitle
(
char
*
psz_subtitle
)
{
char
*
psz_tag
=
malloc
(
(
strlen
(
psz_subtitle
)
/
3
)
+
1
);
...
...
@@ -600,50 +619,39 @@ static char *CreateHtmlSubtitle( char *psz_subtitle )
{
if
(
*
psz_subtitle
==
'\n'
)
{
strcpy
(
psz_html
,
"<br/>"
);
psz_html
+=
5
;
HtmlPut
(
&
psz_html
,
"<br/>"
);
psz_subtitle
++
;
}
else
if
(
*
psz_subtitle
==
'<'
)
{
if
(
!
strncasecmp
(
psz_subtitle
,
"<br/>"
,
5
))
{
strcpy
(
psz_html
,
"<br/>"
);
psz_html
+=
5
;
psz_subtitle
+=
5
;
HtmlCopy
(
&
psz_html
,
&
psz_subtitle
,
"<br/>"
);
}
else
if
(
!
strncasecmp
(
psz_subtitle
,
"<b>"
,
3
)
)
{
strcpy
(
psz_html
,
"<b>"
);
HtmlCopy
(
&
psz_html
,
&
psz_subtitle
,
"<b>"
);
strcat
(
psz_tag
,
"b"
);
psz_html
+=
3
;
psz_subtitle
+=
3
;
}
else
if
(
!
strncasecmp
(
psz_subtitle
,
"<i>"
,
3
)
)
{
strcpy
(
psz_html
,
"<i>"
);
HtmlCopy
(
&
psz_html
,
&
psz_subtitle
,
"<i>"
);
strcat
(
psz_tag
,
"i"
);
psz_html
+=
3
;
psz_subtitle
+=
3
;
}
else
if
(
!
strncasecmp
(
psz_subtitle
,
"<u>"
,
3
)
)
{
strcpy
(
psz_html
,
"<u>"
);
HtmlCopy
(
&
psz_html
,
&
psz_subtitle
,
"<u>"
);
strcat
(
psz_tag
,
"u"
);
psz_html
+=
3
;
psz_subtitle
+=
3
;
}
else
if
(
!
strncasecmp
(
psz_subtitle
,
"<font "
,
6
))
{
const
char
*
psz_attribs
[]
=
{
"face=
\"
"
,
"family=
\"
"
,
"size=
\"
"
,
"color=
\"
"
,
"outline-color=
\"
"
,
"shadow-color=
\"
"
,
"outline-level=
\"
"
,
"shadow-level=
\"
"
,
"back-color=
\"
"
,
"alpha=
\"
"
,
NULL
};
const
char
*
psz_attribs
[]
=
{
"face=
"
,
"family="
,
"size=
"
,
"color=
"
,
"outline-color="
,
"shadow-color=
"
,
"outline-level=
"
,
"shadow-level="
,
"back-color=
"
,
"alpha="
,
NULL
};
strcpy
(
psz_html
,
"<font "
);
HtmlCopy
(
&
psz_html
,
&
psz_subtitle
,
"<font "
);
strcat
(
psz_tag
,
"f"
);
psz_html
+=
6
;
psz_subtitle
+=
6
;
while
(
*
psz_subtitle
!=
'>'
)
{
...
...
@@ -653,13 +661,31 @@ static char *CreateHtmlSubtitle( char *psz_subtitle )
{
int
i_len
=
strlen
(
psz_attribs
[
k
]
);
if
(
!
strncasecmp
(
psz_subtitle
,
psz_attribs
[
k
],
i_len
))
if
(
!
strncasecmp
(
psz_subtitle
,
psz_attribs
[
k
],
i_len
)
)
{
i_len
+=
strcspn
(
psz_subtitle
+
i_len
,
"
\"
"
)
+
1
;
/* */
HtmlPut
(
&
psz_html
,
psz_attribs
[
k
]
);
psz_subtitle
+=
i_len
;
/* */
if
(
*
psz_subtitle
==
'"'
)
{
psz_subtitle
++
;
i_len
=
strcspn
(
psz_subtitle
,
"
\"
"
);
}
else
{
i_len
=
strcspn
(
psz_subtitle
,
"
\t
>"
);
}
HtmlPut
(
&
psz_html
,
"
\"
"
);
if
(
!
strcmp
(
psz_attribs
[
k
],
"color="
)
&&
*
psz_subtitle
>=
'0'
&&
*
psz_subtitle
<=
'9'
)
HtmlPut
(
&
psz_html
,
"#"
);
HtmlNPut
(
&
psz_html
,
psz_subtitle
,
i_len
);
HtmlPut
(
&
psz_html
,
"
\"
"
);
strncpy
(
psz_html
,
psz_subtitle
,
i_len
);
psz_html
+=
i_len
;
psz_subtitle
+=
i_len
;
if
(
*
psz_subtitle
==
'\"'
)
psz_subtitle
++
;
break
;
}
}
...
...
@@ -728,26 +754,19 @@ static char *CreateHtmlSubtitle( char *psz_subtitle )
{
if
(
!
strncasecmp
(
psz_subtitle
,
"<"
,
4
))
{
strcpy
(
psz_html
,
"<"
);
psz_html
+=
4
;
psz_subtitle
+=
4
;
HtmlCopy
(
&
psz_html
,
&
psz_subtitle
,
"<"
);
}
else
if
(
!
strncasecmp
(
psz_subtitle
,
">"
,
4
))
{
strcpy
(
psz_html
,
">"
);
psz_html
+=
4
;
psz_subtitle
+=
4
;
HtmlCopy
(
&
psz_html
,
&
psz_subtitle
,
">"
);
}
else
if
(
!
strncasecmp
(
psz_subtitle
,
"&"
,
5
))
{
strcpy
(
psz_html
,
"&"
);
psz_html
+=
5
;
psz_subtitle
+=
5
;
HtmlCopy
(
&
psz_html
,
&
psz_subtitle
,
"&"
);
}
else
{
strcpy
(
psz_html
,
"&"
);
psz_html
+=
5
;
HtmlPut
(
&
psz_html
,
"&"
);
psz_subtitle
++
;
}
}
...
...
@@ -757,24 +776,22 @@ static char *CreateHtmlSubtitle( char *psz_subtitle )
if
(
psz_html
>
psz_html_start
)
{
/* Check for double whitespace */
if
(((
*
psz_html
==
' '
)
||
(
*
psz_html
==
'\t'
))
&&
((
*
(
psz_html
-
1
)
==
' '
)
||
(
*
(
psz_html
-
1
)
==
'\t'
)))
if
(
(
*
psz_html
==
' '
||
*
psz_html
==
'\t'
)
&&
(
*
(
psz_html
-
1
)
==
' '
||
*
(
psz_html
-
1
)
==
'\t'
)
)
{
strcpy
(
psz_html
,
NO_BREAKING_SPACE
);
psz_html
+=
strlen
(
NO_BREAKING_SPACE
)
-
1
;
HtmlPut
(
&
psz_html
,
NO_BREAKING_SPACE
);
psz_html
--
;
}
}
psz_html
++
;
psz_subtitle
++
;
}
if
(
(
size_t
)(
psz_html
-
psz_html_start
)
>
i_buf_size
-
1
0
)
if
(
(
size_t
)(
psz_html
-
psz_html_start
)
>
i_buf_size
-
5
0
)
{
int
i_len
=
psz_html
-
psz_html_start
;
i_buf_size
+=
1
00
;
i_buf_size
+=
2
00
;
psz_html_start
=
realloc
(
psz_html_start
,
i_buf_size
);
psz_html
=
psz_html_start
+
i_len
;
*
psz_html
=
'\0'
;
...
...
@@ -795,5 +812,7 @@ static char *CreateHtmlSubtitle( char *psz_subtitle )
psz_html_start
=
realloc
(
psz_html_start
,
psz_html
-
psz_html_start
+
1
);
}
free
(
psz_tag
);
return
psz_html_start
;
}
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