Skip to content

Commit

Permalink
Prevent item creation from non-official service endpoints (#1102)
Browse files Browse the repository at this point in the history
  • Loading branch information
defagos authored Dec 12, 2024
1 parent 11c6ca8 commit f1c5581
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
19 changes: 12 additions & 7 deletions Sources/CoreBusiness/DataProvider/Server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ public struct Server {
private let baseUrl: URL
private let queryItems: [URLQueryItem]

/// Creates a server with custom settings.
/// This API will be removed in a future Pillarbox release. Do not use.
///
/// - Parameters:
/// - baseUrl: The base URL of the server.
/// - queryItems: Additional query items to associate with each request.
///
/// Useful for servers which can exactly pose as SRG SSR servers and deliver the same playback metadata format and
/// image scaling capabilities.
/// > Warning: This API will be removed in a future Pillarbox release. Do not use.
public init(baseUrl: URL, queryItems: [URLQueryItem] = []) {
// FIXME: This initializer must be made private after SAM replaces the IL. The assertion must be removed at
// the same time.
assert(Bundle.main.allowsReservedInitializer, "This API will be removed in a future Pillarbox release. Do not use.")
self.baseUrl = baseUrl
self.queryItems = queryItems
}
Expand Down Expand Up @@ -71,3 +69,10 @@ public struct Server {
}
}
}

private extension Bundle {
var allowsReservedInitializer: Bool {
guard let bundleIdentifier = Bundle.main.bundleIdentifier else { return false }
return bundleIdentifier.hasPrefix("ch.srgssr.Pillarbox-demo") || bundleIdentifier.hasPrefix("com.apple.dt.xctest.tool")
}
}
5 changes: 2 additions & 3 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ DEVICES = {

ICON_GLOBS = {
ios: '/Demo/Resources/Assets.xcassets/AppIcon.appiconset/*.png',
tvos: \
'/Demo/Resources/Assets.xcassets/App Icon & Top Shelf Image.brandassets/*/Back.imagestacklayer' \
'/Content.imageset/*.png'
tvos: '/Demo/Resources/Assets.xcassets/App Icon & Top Shelf Image.brandassets/*/Back.imagestacklayer' \
'/Content.imageset/*.png'
}.freeze

SHIELD_SCALES = {
Expand Down

0 comments on commit f1c5581

Please sign in to comment.