From 1f1f7642c3df2f9ec67bbdbdb4d5ed66e126f3ab Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 16 Aug 2015 11:53:30 -0400 Subject: [PATCH] update subtitle escaping --- .../Playback/BaseStreamingService.cs | 4 ++-- .../MediaEncoding/IMediaEncoder.cs | 7 +++++++ MediaBrowser.Controller/Session/SessionInfo.cs | 6 ++++++ .../Encoder/BaseEncoder.cs | 4 ++-- .../Encoder/MediaEncoder.cs | 5 +++++ MediaBrowser.Model/Session/SessionInfoDto.cs | 6 ++++++ .../Session/SessionManager.cs | 2 ++ .../MediaBrowser.WebDashboard.csproj | 17 +++-------------- 8 files changed, 33 insertions(+), 18 deletions(-) diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 8f5301642f..6fba6052f0 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -619,7 +619,7 @@ namespace MediaBrowser.Api.Playback // TODO: Perhaps also use original_size=1920x800 ?? return string.Format("subtitles=filename='{0}'{1},setpts=PTS -{2}/TB", - subtitlePath.Replace('\\', '/').Replace(":/", "\\:/"), + MediaEncoder.EscapeSubtitleFilterPath(subtitlePath), charsetParam, seconds.ToString(UsCulture)); } @@ -627,7 +627,7 @@ namespace MediaBrowser.Api.Playback var mediaPath = state.MediaPath ?? string.Empty; return string.Format("subtitles='{0}:si={1}',setpts=PTS -{2}/TB", - mediaPath.Replace('\\', '/').Replace(":/", "\\:/"), + MediaEncoder.EscapeSubtitleFilterPath(mediaPath), state.InternalSubtitleStreamOffset.ToString(UsCulture), seconds.ToString(UsCulture)); } diff --git a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs index 5bec7980aa..23285b612a 100644 --- a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs +++ b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs @@ -116,5 +116,12 @@ namespace MediaBrowser.Controller.MediaEncoding Task EncodeVideo(EncodingJobOptions options, IProgress progress, CancellationToken cancellationToken); + + /// + /// Escapes the subtitle filter path. + /// + /// The path. + /// System.String. + string EscapeSubtitleFilterPath(string path); } } diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index 64b20c13ef..b3e82f9258 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -125,6 +125,12 @@ namespace MediaBrowser.Controller.Session /// The session controller. public ISessionController SessionController { get; set; } + /// + /// Gets or sets the application icon URL. + /// + /// The application icon URL. + public string AppIconUrl { get; set; } + /// /// Gets or sets the supported commands. /// diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index dd88512fbd..181f147b46 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -865,13 +865,13 @@ namespace MediaBrowser.MediaEncoding.Encoder // TODO: Perhaps also use original_size=1920x800 ?? return string.Format("subtitles=filename='{0}'{1},setpts=PTS -{2}/TB", - subtitlePath.Replace('\\', '/').Replace(":/", "\\:/"), + MediaEncoder.EscapeSubtitleFilterPath(subtitlePath), charsetParam, seconds.ToString(UsCulture)); } return string.Format("subtitles='{0}:si={1}',setpts=PTS -{2}/TB", - state.MediaPath.Replace('\\', '/').Replace(":/", "\\:/"), + MediaEncoder.EscapeSubtitleFilterPath(state.MediaPath), state.InternalSubtitleStreamOffset.ToString(UsCulture), seconds.ToString(UsCulture)); } diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index c059a8b54c..50b6a94aae 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -765,6 +765,11 @@ namespace MediaBrowser.MediaEncoding.Encoder } } + public string EscapeSubtitleFilterPath(string path) + { + return path.Replace('\\', '/').Replace(":/", "\\:/").Replace("'", "'\\\\\\'"); + } + /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// diff --git a/MediaBrowser.Model/Session/SessionInfoDto.cs b/MediaBrowser.Model/Session/SessionInfoDto.cs index 98df3efe55..da8ab9b8a3 100644 --- a/MediaBrowser.Model/Session/SessionInfoDto.cs +++ b/MediaBrowser.Model/Session/SessionInfoDto.cs @@ -99,6 +99,12 @@ namespace MediaBrowser.Model.Session /// /// The device id. public string DeviceId { get; set; } + + /// + /// Gets or sets the application icon URL. + /// + /// The application icon URL. + public string AppIconUrl { get; set; } /// /// Gets or sets a value indicating whether [supports remote control]. diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index c2160f48a9..70a4cb4392 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -161,6 +161,7 @@ namespace MediaBrowser.Server.Implementations.Session if (capabilities != null) { + info.AppIconUrl = capabilities.IconUrl; ReportCapabilities(info, capabilities, false); } } @@ -1476,6 +1477,7 @@ namespace MediaBrowser.Server.Implementations.Session NowPlayingItem = session.NowPlayingItem, SupportsRemoteControl = session.SupportsMediaControl, PlayState = session.PlayState, + AppIconUrl = session.AppIconUrl, TranscodingInfo = session.NowPlayingItem == null ? null : session.TranscodingInfo }; diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 42a9c5c1be..a90fbaec84 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -156,6 +156,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -565,12 +568,6 @@ PreserveNewest - - PreserveNewest - - - PreserveNewest - PreserveNewest @@ -802,9 +799,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest @@ -2207,11 +2201,6 @@ PreserveNewest - - - PreserveNewest - - PreserveNewest