Merge pull request #3801 from bernarden/bug/3295-return-all-urls-with-https-scheme

Replaces scheme to https for all urls returned to client side.
pull/3816/head
Jamie 4 years ago committed by GitHub
commit 9b4792babe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -98,7 +98,7 @@ namespace Ombi.Core.Engine
};
newSeason.Episodes.Add(new EpisodeRequests
{
Url = e.url,
Url = e.url.ToHttpsUrl(),
Title = e.name,
AirDate = e.airstamp.HasValue() ? DateTime.Parse(e.airstamp) : DateTime.MinValue,
EpisodeNumber = e.number,
@ -111,7 +111,7 @@ namespace Ombi.Core.Engine
// We already have the season, so just add the episode
season.Episodes.Add(new EpisodeRequests
{
Url = e.url,
Url = e.url.ToHttpsUrl(),
Title = e.name,
AirDate = e.airstamp.HasValue() ? DateTime.Parse(e.airstamp) : DateTime.MinValue,
EpisodeNumber = e.number,

@ -85,10 +85,10 @@ namespace Ombi.Core.Engine.V2
if (lidarrArtistTask != null)
{
var artistResult = await lidarrArtistTask;
info.Banner = artistResult.images?.FirstOrDefault(x => x.coverType.Equals("banner", StringComparison.InvariantCultureIgnoreCase))?.url.Replace("http", "https");
info.Logo = artistResult.images?.FirstOrDefault(x => x.coverType.Equals("logo", StringComparison.InvariantCultureIgnoreCase))?.url.Replace("http", "https");
info.Poster = artistResult.images?.FirstOrDefault(x => x.coverType.Equals("poster", StringComparison.InvariantCultureIgnoreCase))?.url.Replace("http", "https");
info.FanArt = artistResult.images?.FirstOrDefault(x => x.coverType.Equals("fanart", StringComparison.InvariantCultureIgnoreCase))?.url.Replace("http", "https");
info.Banner = artistResult.images?.FirstOrDefault(x => x.coverType.Equals("banner", StringComparison.InvariantCultureIgnoreCase))?.url.ToHttpsUrl();
info.Logo = artistResult.images?.FirstOrDefault(x => x.coverType.Equals("logo", StringComparison.InvariantCultureIgnoreCase))?.url.ToHttpsUrl();
info.Poster = artistResult.images?.FirstOrDefault(x => x.coverType.Equals("poster", StringComparison.InvariantCultureIgnoreCase))?.url.ToHttpsUrl();
info.FanArt = artistResult.images?.FirstOrDefault(x => x.coverType.Equals("fanart", StringComparison.InvariantCultureIgnoreCase))?.url.ToHttpsUrl();
info.Overview = artistResult.overview;
}
@ -108,11 +108,11 @@ namespace Ombi.Core.Engine.V2
{
if ((cover.thumbnails?.small ?? string.Empty).HasValue())
{
return new AlbumArt(cover.thumbnails.small);
return new AlbumArt(cover.thumbnails.small.ToHttpsUrl());
}
if ((cover.thumbnails?.large ?? string.Empty).HasValue())
{
return new AlbumArt(cover.thumbnails.large);
return new AlbumArt(cover.thumbnails.large.ToHttpsUrl());
}
}
@ -152,69 +152,69 @@ namespace Ombi.Core.Engine.V2
switch (relation.TypeId)
{
case RelationLinks.AllMusic:
links.AllMusic = relation.Url?.Resource;
links.AllMusic = relation.Url?.Resource.ToHttpsUrl();
break;
case RelationLinks.BbcMusic:
links.BbcMusic = relation.Url?.Resource;
links.BbcMusic = relation.Url?.Resource.ToHttpsUrl();
break;
case RelationLinks.Discogs:
links.Discogs = relation.Url?.Resource;
links.Discogs = relation.Url?.Resource.ToHttpsUrl();
break;
case RelationLinks.Homepage:
links.HomePage = relation.Url?.Resource;
links.HomePage = relation.Url?.Resource.ToHttpsUrl();
break;
case RelationLinks.Imdb:
links.Imdb = relation.Url?.Resource;
links.Imdb = relation.Url?.Resource.ToHttpsUrl();
break;
case RelationLinks.LastFm:
links.LastFm = relation.Url?.Resource;
links.LastFm = relation.Url?.Resource.ToHttpsUrl();
break;
case RelationLinks.MySpace:
links.MySpace = relation.Url?.Resource;
links.MySpace = relation.Url?.Resource.ToHttpsUrl();
break;
case RelationLinks.OnlineCommunity:
links.OnlineCommunity = relation.Url?.Resource;
links.OnlineCommunity = relation.Url?.Resource.ToHttpsUrl();
break;
case RelationLinks.SocialNetwork:
if ((relation.Url?.Resource ?? string.Empty).Contains("twitter", CompareOptions.IgnoreCase))
{
links.Twitter = relation.Url?.Resource;
links.Twitter = relation.Url?.Resource.ToHttpsUrl();
}
if ((relation.Url?.Resource ?? string.Empty).Contains("facebook", CompareOptions.IgnoreCase))
{
links.Facebook = relation.Url?.Resource;
links.Facebook = relation.Url?.Resource.ToHttpsUrl();
}
if ((relation.Url?.Resource ?? string.Empty).Contains("instagram", CompareOptions.IgnoreCase))
{
links.Instagram = relation.Url?.Resource;
links.Instagram = relation.Url?.Resource.ToHttpsUrl();
}
if ((relation.Url?.Resource ?? string.Empty).Contains("vk", CompareOptions.IgnoreCase))
{
links.Vk = relation.Url?.Resource;
links.Vk = relation.Url?.Resource.ToHttpsUrl();
}
break;
case RelationLinks.Streams:
if ((relation.Url?.Resource ?? string.Empty).Contains("spotify", CompareOptions.IgnoreCase))
{
links.Spotify = relation.Url?.Resource;
links.Spotify = relation.Url?.Resource.ToHttpsUrl();
}
if ((relation.Url?.Resource ?? string.Empty).Contains("deezer", CompareOptions.IgnoreCase))
{
links.Deezer = relation.Url?.Resource;
links.Deezer = relation.Url?.Resource.ToHttpsUrl();
}
break;
case RelationLinks.YouTube:
links.YouTube = relation.Url?.Resource;
links.YouTube = relation.Url?.Resource.ToHttpsUrl();
break;
case RelationLinks.Download:
if ((relation.Url?.Resource ?? string.Empty).Contains("google", CompareOptions.IgnoreCase))
{
links.Google = relation.Url?.Resource;
links.Google = relation.Url?.Resource.ToHttpsUrl();
}
if ((relation.Url?.Resource ?? string.Empty).Contains("apple", CompareOptions.IgnoreCase))
{
links.Apple = relation.Url?.Resource;
links.Apple = relation.Url?.Resource.ToHttpsUrl();
}
break;

@ -1,11 +1,9 @@
using System;
using AutoMapper;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Threading.Tasks;
using Ombi.Core.Rule.Interfaces;
using Ombi.Store.Repository.Requests;
using Ombi.Core.Authentication;
@ -85,7 +83,7 @@ namespace Ombi.Core.Engine.V2
};
newSeason.Episodes.Add(new EpisodeRequests
{
Url = e.url,
Url = e.url.ToHttpsUrl(),
Title = e.name,
AirDate = e.airstamp,
EpisodeNumber = e.number,
@ -98,7 +96,7 @@ namespace Ombi.Core.Engine.V2
// We already have the season, so just add the episode
season.Episodes.Add(new EpisodeRequests
{
Url = e.url,
Url = e.url.ToHttpsUrl(),
Title = e.name,
AirDate = e.airstamp,
EpisodeNumber = e.number,
@ -141,7 +139,7 @@ namespace Ombi.Core.Engine.V2
if (!string.IsNullOrEmpty(item.Images?.Medium))
{
item.Images.Medium = item.Images.Medium.Replace("http:", "https:");
item.Images.Medium = item.Images.Medium.ToHttpsUrl();
}
if (item.Cast?.Any() ?? false)
@ -150,7 +148,7 @@ namespace Ombi.Core.Engine.V2
{
if (!string.IsNullOrEmpty(cast.Character?.Image?.Medium))
{
cast.Character.Image.Medium = cast.Character?.Image?.Medium.Replace("http:", "https:");
cast.Character.Image.Medium = cast.Character?.Image?.Medium.ToHttpsUrl();
}
}
}
@ -168,9 +166,9 @@ namespace Ombi.Core.Engine.V2
return model;
}
model.Trailer = result.Trailer?.AbsoluteUri ?? string.Empty;
model.Trailer = result.Trailer?.AbsoluteUri.ToHttpsUrl() ?? string.Empty;
model.Certification = result.Certification;
model.Homepage = result.Homepage?.AbsoluteUri ?? string.Empty;
model.Homepage = result.Homepage?.AbsoluteUri.ToHttpsUrl() ?? string.Empty;
}
return model;
}

@ -55,7 +55,7 @@ namespace Ombi.Core.Helpers
FirstAir = dt;
// For some reason the poster path is always http
PosterPath = ShowInfo.image?.medium.Replace("http:", "https:");
PosterPath = ShowInfo.image?.medium.ToHttpsUrl();
return this;
}
@ -113,7 +113,7 @@ namespace Ombi.Core.Helpers
EpisodeNumber = ep.number,
AirDate = FormatDate(ep.airdate),
Title = ep.name,
Url = ep.url
Url = ep.url.ToHttpsUrl()
}
},
SeasonNumber = ep.season,
@ -126,7 +126,7 @@ namespace Ombi.Core.Helpers
EpisodeNumber = ep.number,
AirDate = FormatDate(ep.airdate),
Title = ep.name,
Url = ep.url
Url = ep.url.ToHttpsUrl()
});
}
}
@ -146,7 +146,7 @@ namespace Ombi.Core.Helpers
EpisodeNumber = ep.number,
AirDate = FormatDate(ep.airdate),
Title = ep.name,
Url = ep.url
Url = ep.url.ToHttpsUrl()
});
}
}
@ -170,7 +170,7 @@ namespace Ombi.Core.Helpers
EpisodeNumber = ep.number,
AirDate = FormatDate(ep.airdate),
Title = ep.name,
Url = ep.url
Url = ep.url.ToHttpsUrl()
});
}
}
@ -200,7 +200,7 @@ namespace Ombi.Core.Helpers
EpisodeNumber = ep.number,
AirDate = FormatDate(ep.airdate),
Title = ep.name,
Url = ep.url,
Url = ep.url.ToHttpsUrl()
});
}
}
@ -216,7 +216,7 @@ namespace Ombi.Core.Helpers
EpisodeNumber = ep.number,
AirDate = FormatDate(ep.airdate),
Title = ep.name,
Url = ep.url,
Url = ep.url.ToHttpsUrl()
});
seasonRequests.Add(newRequest);
}

@ -40,5 +40,14 @@ namespace Ombi.Helpers.Tests
Assert.AreEqual(expectedUrl, sourceUrl.ToHttpsUrl(), "Should return the unchanged invalid URL");
}
[Test]
public void ToHttpsUrl_ShouldReturnNull_NullUrl()
{
const string sourceUrl = null;
const string expectedUrl = null;
Assert.AreEqual(expectedUrl, sourceUrl.ToHttpsUrl(), "Should return null for null URL");
}
}
}

@ -62,7 +62,7 @@ namespace Ombi.Helpers.Tests
var expected = (string)d.ExpectedResult;
var args = d.Arguments.ToList();
args.Add(true);
var newExpected = expected.Replace("http://", "https://");
var newExpected = expected.ToHttpsUrl();
if (args.Contains(80))
{
newExpected = expected;
@ -99,7 +99,7 @@ namespace Ombi.Helpers.Tests
}
}
args.Add(true);
var newExpected = expected.Replace("http://", "https://");
var newExpected = expected.ToHttpsUrl();
if (args.Contains(80))
{
newExpected = expected;

@ -131,7 +131,7 @@ namespace Ombi.Helpers
public static string ToHttpsUrl(this string currentUrl)
{
return currentUrl.Replace("http://", "https://");
return currentUrl?.Replace("http://", "https://");
}
}
}

@ -56,8 +56,10 @@ namespace Ombi.Mapping.Profiles
.ForMember(dest => dest.Runtime, opts => opts.MapFrom(src => src.Runtime.ToString()))
.ForMember(dest => dest.Title, opts => opts.MapFrom(src => src.Title))
.ForMember(dest => dest.Status, opts => opts.MapFrom(src => TraktEnumHelper.GetDescription(src.Status)))
.ForMember(dest => dest.Trailer, opts => opts.MapFrom(src => src.Trailer))
.ForMember(dest => dest.Homepage, opts => opts.MapFrom(src => src.Homepage));
.ForMember(dest => dest.Trailer,
opts => opts.MapFrom(src => src.Trailer.ToString().ToHttpsUrl()))
.ForMember(dest => dest.Homepage,
opts => opts.MapFrom(src => src.Homepage.ToString().ToHttpsUrl()));
}
}
}

@ -30,7 +30,7 @@ namespace Ombi.Mapping.Profiles
.ForMember(dest => dest.Banner,
opts => opts.MapFrom(src =>
!string.IsNullOrEmpty(src.image.medium)
? src.image.medium.Replace("http", "https")
? src.image.medium.ToHttpsUrl()
: string.Empty))
.ForMember(dest => dest.Status, opts => opts.MapFrom(src => src.status));
@ -45,8 +45,8 @@ namespace Ombi.Mapping.Profiles
.ForMember(dest => dest.Timezone, opts => opts.MapFrom(src => src.timezone));
CreateMap<Api.TvMaze.Models.V2.Image, Images>()
.ForMember(dest => dest.Medium, opts => opts.MapFrom(src => src.medium))
.ForMember(dest => dest.Original, opts => opts.MapFrom(src => src.original));
.ForMember(dest => dest.Medium, opts => opts.MapFrom(src => src.medium.ToHttpsUrl()))
.ForMember(dest => dest.Original, opts => opts.MapFrom(src => src.original.ToHttpsUrl()));
CreateMap<Api.TvMaze.Models.V2.Cast, CastViewModel>()
.ForMember(dest => dest.Character, opts => opts.MapFrom(src => src.character))
@ -58,7 +58,7 @@ namespace Ombi.Mapping.Profiles
.ForMember(dest => dest.Id, opts => opts.MapFrom(src => src.id))
.ForMember(dest => dest.Name, opts => opts.MapFrom(src => src.name))
.ForMember(dest => dest.Image, opts => opts.MapFrom(src => src.image))
.ForMember(dest => dest.Url, opts => opts.MapFrom(src => src.url));
.ForMember(dest => dest.Url, opts => opts.MapFrom(src => src.url.ToHttpsUrl()));
CreateMap<Api.TvMaze.Models.V2.Crew, CrewViewModel>()
.ForMember(dest => dest.Person, opts => opts.MapFrom(src => src.person))
@ -73,7 +73,7 @@ namespace Ombi.Mapping.Profiles
CreateMap<Api.TvMaze.Models.V2.Character, CharacterViewModel>()
.ForMember(dest => dest.Name, opts => opts.MapFrom(src => src.name))
.ForMember(dest => dest.Id, opts => opts.MapFrom(src => src.id))
.ForMember(dest => dest.Url, opts => opts.MapFrom(src => src.url))
.ForMember(dest => dest.Url, opts => opts.MapFrom(src => src.url.ToHttpsUrl()))
.ForMember(dest => dest.Image, opts => opts.MapFrom(src => src.image));
CreateMap<SearchTvShowViewModel, SearchFullInfoTvShowViewModel>().ReverseMap();

Loading…
Cancel
Save