From a2f22b5b45dba80509f10539d2675d92cc3ebd60 Mon Sep 17 00:00:00 2001 From: Lee SeJin Date: Sun, 14 Jan 2024 21:07:13 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[Fix]=20#352=20-=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=ED=95=84=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EB=B7=B0=EC=9D=98=20?= =?UTF-8?q?=EA=B8=B0=EB=B3=B8=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PokeFeature/Sources/Components/PokeProfileCardView.swift | 1 + .../PokeFeature/Sources/Components/PokeProfileImageView.swift | 1 + .../Sources/PokeMainScene/Views/ProfileCardGroupView.swift | 2 ++ 3 files changed, 4 insertions(+) diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/Components/PokeProfileCardView.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Components/PokeProfileCardView.swift index 5d38933b..b487c352 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Sources/Components/PokeProfileCardView.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Components/PokeProfileCardView.swift @@ -30,6 +30,7 @@ public final class PokeProfileCardView: UIView, PokeCompatible { imageView.backgroundColor = DSKitAsset.Colors.gray700.color imageView.clipsToBounds = true imageView.contentMode = .scaleAspectFill + imageView.image = DSKitAsset.Assets.iconDefaultProfile.image return imageView }() diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/Components/PokeProfileImageView.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Components/PokeProfileImageView.swift index 53c89713..1570fd1d 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Sources/Components/PokeProfileImageView.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Components/PokeProfileImageView.swift @@ -29,6 +29,7 @@ public final class PokeProfileImageView: UIImageView { private func setUI() { self.backgroundColor = DSKitAsset.Colors.gray700.color + self.image = DSKitAsset.Assets.iconDefaultProfile.image self.clipsToBounds = true self.layer.borderWidth = 2 self.contentMode = .scaleAspectFill diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/Views/ProfileCardGroupView.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/Views/ProfileCardGroupView.swift index 3179b84a..3419434e 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/Views/ProfileCardGroupView.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/Views/ProfileCardGroupView.swift @@ -37,9 +37,11 @@ public final class ProfileCardGroupView: UIView, PokeCompatible { // MARK: - UI Components private let friendProfileImageView = UIImageView().then { + $0.image = DSKitAsset.Assets.iconDefaultProfile.image $0.layer.cornerRadius = 15 $0.backgroundColor = DSKitAsset.Colors.gray700.color $0.clipsToBounds = true + $0.contentMode = .scaleAspectFill } private let friendNameLabel = UILabel().then { From 6b7622b956df4b4f293d35ef62b6e0f7a7b8f209 Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Sun, 14 Jan 2024 21:54:39 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[Fix]=20#352=20-=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20URL=EC=9D=84=20PercentEncoding=ED=95=98=EA=B3=A0=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EB=A1=9C=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SOPT-iOS/Projects/Core/Sources/Utils/setImage.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SOPT-iOS/Projects/Core/Sources/Utils/setImage.swift b/SOPT-iOS/Projects/Core/Sources/Utils/setImage.swift index 71976889..9dd7366c 100644 --- a/SOPT-iOS/Projects/Core/Sources/Utils/setImage.swift +++ b/SOPT-iOS/Projects/Core/Sources/Utils/setImage.swift @@ -10,6 +10,11 @@ import Kingfisher public extension UIImageView { func setImage(with urlString: String, placeholder: UIImage? = nil, completion: ((UIImage?) -> Void)? = nil) { + guard let urlString = urlString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else { + print("URL 인코딩 실패") + return + } + let cache = ImageCache.default if urlString == "" { self.image = placeholder From 3ad654d9f1e0448cb550b2b86bc2e902c7c56edd Mon Sep 17 00:00:00 2001 From: Lee SeJin Date: Mon, 15 Jan 2024 20:28:34 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[Fix]=20#352=20-=20=EC=A4=91=EB=B3=B5?= =?UTF-8?q?=EB=90=98=EC=96=B4=20percentEncoding=20=EB=90=A0=20=EC=88=98=20?= =?UTF-8?q?=EC=9E=88=EB=8A=94=20=EB=AC=B8=EC=A0=9C=EB=A5=BC=20=EB=B0=A9?= =?UTF-8?q?=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Extension/Foundation+/String+.swift | 27 +++++++++++++++++++ .../Core/Sources/Utils/setImage.swift | 5 +++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/SOPT-iOS/Projects/Core/Sources/Extension/Foundation+/String+.swift b/SOPT-iOS/Projects/Core/Sources/Extension/Foundation+/String+.swift index 55bebb5b..197f9c34 100644 --- a/SOPT-iOS/Projects/Core/Sources/Extension/Foundation+/String+.swift +++ b/SOPT-iOS/Projects/Core/Sources/Extension/Foundation+/String+.swift @@ -75,3 +75,30 @@ public extension String { return map({String($0)}).last } } + +public extension String { + func isPercentEncoded() -> Bool { + guard let decodedString = self.removingPercentEncoding, + let decodedData = decodedString.data(using: .utf8) + else { return false } + + let encodedData = self.data(using: .utf8) + + return encodedData != decodedData + } + + func removePercentEncodingIfNeeded() -> String { + func removePercentEncodingRecursively(with string: String, attempts: Int) -> String { + guard attempts > 0 else { return string } + + let decodedString = string.removingPercentEncoding ?? string + return decodedString.isPercentEncoded() ? removePercentEncodingRecursively(with: decodedString, attempts: attempts - 1) : decodedString + } + + guard isPercentEncoded(), + let decodedString = self.removingPercentEncoding + else { return self } + + return removePercentEncodingRecursively(with: decodedString, attempts: 2) + } +} diff --git a/SOPT-iOS/Projects/Core/Sources/Utils/setImage.swift b/SOPT-iOS/Projects/Core/Sources/Utils/setImage.swift index 9dd7366c..47666599 100644 --- a/SOPT-iOS/Projects/Core/Sources/Utils/setImage.swift +++ b/SOPT-iOS/Projects/Core/Sources/Utils/setImage.swift @@ -10,7 +10,10 @@ import Kingfisher public extension UIImageView { func setImage(with urlString: String, placeholder: UIImage? = nil, completion: ((UIImage?) -> Void)? = nil) { - guard let urlString = urlString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else { + guard let urlString = urlString + .removePercentEncodingIfNeeded() + .addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) + else { print("URL 인코딩 실패") return }