From cb5547fafc005027989daf2a0916c8a333369c4b Mon Sep 17 00:00:00 2001 From: Prathieshna Vekneswaran Date: Thu, 27 Mar 2025 15:50:56 +0530 Subject: [PATCH] Special characters fix --- .../openarchive/services/internetarchive/IaConduit.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/opendasharchive/openarchive/services/internetarchive/IaConduit.kt b/app/src/main/java/net/opendasharchive/openarchive/services/internetarchive/IaConduit.kt index dee47500..b4b8abbc 100644 --- a/app/src/main/java/net/opendasharchive/openarchive/services/internetarchive/IaConduit.kt +++ b/app/src/main/java/net/opendasharchive/openarchive/services/internetarchive/IaConduit.kt @@ -179,7 +179,7 @@ class IaConduit(media: Media, context: Context) : Conduit(media, context) { } if (mMedia.location.isNotEmpty()) { - builder.add("x-archive-meta-location", mMedia.location) + builder.add("x-archive-meta-location", sanitizeHeaderValue(mMedia.location)) } if (mMedia.tags.isNotEmpty()) { @@ -191,7 +191,7 @@ class IaConduit(media: Media, context: Context) : Conduit(media, context) { } if (mMedia.description.isNotEmpty()) { - builder.add("x-archive-meta-description", mMedia.description) + builder.add("x-archive-meta-description", sanitizeHeaderValue(mMedia.description)) } if (mMedia.title.isNotEmpty()) { @@ -246,4 +246,8 @@ class IaConduit(media: Media, context: Context) : Conduit(media, context) { }) } + + private fun sanitizeHeaderValue(value: String): String { + return value.replace("[^\\x20-\\x7E]".toRegex(), "") // Removes non-ASCII characters + } }