Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent item creation from non-official service endpoints #1102

Merged
merged 3 commits into from
Dec 12, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
}
}
Loading