Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagecpp
 func parseEncryptions() -> [String: Encryption] {
        guard let document = document else {
            return [:]
        }
        var encryptions: [String: Encryption] = [:]
        

        // Loop through <EncryptedData> elements..

        for encryptedDataElement in document.xpath("./enc:EncryptedData") {
            guard let algorithm = encryptedDataElement.firstChild(xpath: "enc:EncryptionMethod")?.attr("Algorithm
                var resourceURI = encryptedDataElement.firstChild(xpath:"enc:CipherData/enc:CipherReference")?.attr("URI")?.removingPercentEncoding else
            {
                continue
            }
            resourceURI = normalize(base: "/", href: resourceURI)
            var encryption = Encryption(algorithm: algorithm)

            // LCP. Tag LCP protected resources.

            let keyInfoURI = encryptedDataElement.firstChild(xpath: "ds:KeyInfo/ds:RetrievalMethod")?.attr("URI")
            if keyInfoURI == "license.lcpl#/encryption/content_key",
                drm?.brand == DRM.Brand.lcp
            {
                 encryption.scheme = drm?.scheme.rawValue
             }
             // LCP END.
             
             if drm?.brand == .adobe {
                 encryption.scheme = drm?.scheme.rawValue
             }
. . .

    func parseEncryptions() -> [String: Encryption] {

        guard let document = document else {

            return [:]

        }

        var encryptions: [String: Encryption] = [:]

        

        // Loop through <EncryptedData> elements..

        for encryptedDataElement in document.xpath("./enc:EncryptedData") {

            guard let algorithm = encryptedDataElement.firstChild(xpath: "enc:EncryptionMethod")?.attr("Algorithm"),

                var resourceURI = encryptedDataElement.firstChild(xpath:"enc:CipherData/enc:CipherReference")?.attr("URI")?.removingPercentEncoding else

            {

                continue

...

}

            resourceURI = normalize(base: "/", href: resourceURI)

            var encryption = Encryption(algorithm: algorithm)

            // LCP. Tag LCP protected resources.

            let keyInfoURI = encryptedDataElement.firstChild(xpath: "ds:KeyInfo/ds:RetrievalMethod")?.attr("URI")

            if keyInfoURI == "license.lcpl#/encryption/content_key",

                drm?.brand == DRM.Brand.lcp

            {

                 encryption.scheme = drm?.scheme.rawValue

             }

             // LCP END.

             

             if drm?.brand == .adobe {

                 encryption.scheme = drm?.scheme.rawValue

             }

. . .


Commit:

https://github.com/NYPL-Simplified/r2-streamer-swift/commit/08c6d6a204cebff5137f868794a412b453437a5b

In `Parser/EPUB/EPUBEncryptionParser.swift` changed how Adobe encryption scheme is assigned: 


Code Block
languagecpp
scheme = drm?.scheme.rawValue

In `Parser/EPUB/EPUBParser.swift` added `links` to the initialized publication


Code Block
languagecpp
publication.links = links


publication.links = links

...