From f983913e52ed5f3317969898d3c2254a9e791825 Mon Sep 17 00:00:00 2001 From: Nobuhiro Ito Date: Thu, 8 Aug 2019 14:08:09 +0900 Subject: [PATCH] Escape HTML entities --- Package.resolved | 9 +++++++++ Package.swift | 5 ++++- Sources/LicensePlistCore/Entity/LicenseHTMLHolder.swift | 5 +++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Package.resolved b/Package.resolved index 95f2b70..7cb99a7 100644 --- a/Package.resolved +++ b/Package.resolved @@ -55,6 +55,15 @@ "version": "0.9.0" } }, + { + "package": "HTMLEntities", + "repositoryURL": "https://github.com/IBM-Swift/swift-html-entities.git", + "state": { + "branch": null, + "revision": "3b778b3ab061684db024eaf38c576887b42918aa", + "version": "3.0.13" + } + }, { "package": "Yaml", "repositoryURL": "https://github.com/behrang/YamlSwift.git", diff --git a/Package.swift b/Package.swift index 4828744..666f846 100644 --- a/Package.swift +++ b/Package.swift @@ -16,7 +16,9 @@ let package = Package( .package(url: "https://github.com/IBM-Swift/HeliumLogger.git", from: "1.8.0"), .package(url: "https://github.com/behrang/YamlSwift.git", - from: "3.4.0") + from: "3.4.0"), + .package(url: "https://github.com/IBM-Swift/swift-html-entities.git", + from: "3.0.0") ], targets: [ .target( @@ -33,6 +35,7 @@ let package = Package( "APIKit", "Commander", "HeliumLogger", + "HTMLEntities", "Yaml" ] ), diff --git a/Sources/LicensePlistCore/Entity/LicenseHTMLHolder.swift b/Sources/LicensePlistCore/Entity/LicenseHTMLHolder.swift index ad800d3..e3ad51d 100644 --- a/Sources/LicensePlistCore/Entity/LicenseHTMLHolder.swift +++ b/Sources/LicensePlistCore/Entity/LicenseHTMLHolder.swift @@ -1,5 +1,6 @@ import Foundation import LoggerAPI +import HTMLEntities struct LicenseHTMLHolder { let html: String @@ -20,8 +21,8 @@ struct LicenseHTMLHolder { """ licenses.forEach { license in html += """ -

\(license.name(withVersion: options.config.addVersionNumbers))

-
\(license.body)
+

\(license.name(withVersion: options.config.addVersionNumbers).htmlEscape())

+
\(license.body.htmlEscape())
""" }