-
Notifications
You must be signed in to change notification settings - Fork 162
Ensure that bundle identifiers are valid URL host components #1069
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
Changes from 1 commit
28b9522
0e62ffc
b46b5d3
bfa673b
98c6a58
399ed9a
a7310b7
221891a
890e323
3c56a2d
13b11fb
414ef9c
61cc5e2
5369b1c
4805a05
0f2f8ef
c2442bc
71b27b6
3d063ef
f97e6d3
9478d47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,8 +51,13 @@ import SymbolKit | |
| public class OutOfProcessReferenceResolver: ExternalDocumentationSource, GlobalExternalSymbolResolver { | ||
| private let externalLinkResolvingClient: ExternalLinkResolving | ||
|
|
||
| @available(*, deprecated, renamed: "id", message: "Use 'id' instead. This deprecated API will be removed after 6.2 is released") | ||
| public var bundleIdentifier: String { | ||
| id.rawValue | ||
| } | ||
|
|
||
| /// The bundle identifier for the reference resolver in the other process. | ||
| public let bundleIdentifier: String | ||
| public let id: DocumentationBundle.Identifier | ||
|
||
|
|
||
| /// Creates a new reference resolver that interacts with another executable. | ||
| /// | ||
|
|
@@ -77,20 +82,27 @@ public class OutOfProcessReferenceResolver: ExternalDocumentationSource, GlobalE | |
| throw Error.invalidBundleIdentifierOutputFromExecutable(processLocation) | ||
| } | ||
|
|
||
| self.bundleIdentifier = decodedBundleIdentifier | ||
| self.id = .init(rawValue: decodedBundleIdentifier) | ||
| self.externalLinkResolvingClient = longRunningProcess | ||
| } | ||
|
|
||
| @available(*, deprecated, renamed: "init(id:server:convertRequestIdentifier:)", message: "Use 'init(id:server:convertRequestIdentifier:)' instead. This deprecated API will be removed after 6.2 is released") | ||
| public init(bundleIdentifier: String, server: DocumentationServer, convertRequestIdentifier: String?) throws { | ||
| self.id = .init(rawValue: bundleIdentifier) | ||
| self.externalLinkResolvingClient = LongRunningService( | ||
| server: server, convertRequestIdentifier: convertRequestIdentifier) | ||
| } | ||
|
|
||
| /// Creates a new reference resolver that interacts with a documentation service. | ||
| /// | ||
| /// The documentation service is expected to be able to handle messages of kind "resolve-reference". | ||
| /// | ||
| /// - Parameters: | ||
| /// - bundleIdentifier: The bundle identifier the server can resolve references for. | ||
| /// - id: The bundle identifier the server can resolve references for. | ||
| /// - server: The server to send link resolution requests to. | ||
| /// - convertRequestIdentifier: The identifier that the resolver will use for convert requests that it sends to the server. | ||
| public init(bundleIdentifier: String, server: DocumentationServer, convertRequestIdentifier: String?) throws { | ||
| self.bundleIdentifier = bundleIdentifier | ||
| public init(id: DocumentationBundle.Identifier, server: DocumentationServer, convertRequestIdentifier: String?) throws { | ||
| self.id = id | ||
| self.externalLinkResolvingClient = LongRunningService( | ||
| server: server, convertRequestIdentifier: convertRequestIdentifier) | ||
| } | ||
|
|
@@ -103,7 +115,7 @@ public class OutOfProcessReferenceResolver: ExternalDocumentationSource, GlobalE | |
| return resolved | ||
|
|
||
| case let .unresolved(unresolvedReference): | ||
| guard unresolvedReference.bundleIdentifier == bundleIdentifier else { | ||
| guard unresolvedReference.bundleIdentifier == id.rawValue else { | ||
| fatalError(""" | ||
| Attempted to resolve a local reference externally: \(unresolvedReference.description.singleQuoted). | ||
| DocC should never pass a reference to an external resolver unless it matches that resolver's bundle identifier. | ||
|
|
@@ -243,7 +255,7 @@ public class OutOfProcessReferenceResolver: ExternalDocumentationSource, GlobalE | |
|
|
||
| private func resolvedReference(for resolvedInformation: ResolvedInformation) -> ResolvedTopicReference { | ||
| return ResolvedTopicReference( | ||
| bundleIdentifier: bundleIdentifier, | ||
| bundleIdentifier: id.rawValue, | ||
| path: resolvedInformation.url.path, | ||
| fragment: resolvedInformation.url.fragment, | ||
| sourceLanguages: sourceLanguages(for: resolvedInformation) | ||
|
|
@@ -767,13 +779,13 @@ extension OutOfProcessReferenceResolver: ConvertServiceFallbackResolver { | |
| } | ||
|
|
||
| func resolveInformationForAsset(named assetName: String) throws -> DataAsset { | ||
| let assetReference = AssetReference(assetName: assetName, bundleIdentifier: bundleIdentifier) | ||
| let assetReference = AssetReference(assetName: assetName, bundleIdentifier: id.rawValue) | ||
| if let asset = assetCache[assetReference] { | ||
| return asset | ||
| } | ||
|
|
||
| let response = try externalLinkResolvingClient.sendAndWait( | ||
| request: Request.asset(AssetReference(assetName: assetName, bundleIdentifier: bundleIdentifier)) | ||
| request: Request.asset(AssetReference(assetName: assetName, bundleIdentifier: id.rawValue)) | ||
| ) as Response | ||
|
|
||
| switch response { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is
bundleIDnotid. Looks like we make some mismatch after the Code Review. cc @d-ronnqvistThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I must have missed that in the PR. If I touch this code again in the near future I can update the deprecation message. If not, this deprecated property is scheduled to be removed after the next version (6.2) is released, so the problem will go away on its own.