fix: unicode paths

* improve sanitization
* Fix InputType to allow negative decimals to properly spoof more locations

Co-authored-by: auth <64337177+authorisation@users.noreply.github.com>
This commit is contained in:
TheVisual 2023-08-05 09:59:02 -05:00 committed by GitHub
parent e89901a2f6
commit 4182f53f23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 11 deletions

View File

@ -99,3 +99,4 @@ When redistributing the software, it must remain under the same [GPLv3](https://
- [RevealedSoulEven](https://github.com/revealedsouleven)
- [iBasim](https://github.com/ibasim)
- [xerta555](https://github.com/xerta555)
- [TheVisual](https://github.com/TheVisual)

View File

@ -127,7 +127,7 @@ class MediaDownloader : Feature("MediaDownloader", loadParams = FeatureLoadParam
val downloadOptions = context.config.options(ConfigProperty.DOWNLOAD_OPTIONS)
val sanitizedPathPrefix = pathPrefix
.replace(" ", "_")
.replace(Regex("[\\\\:*?\"<>|]"), "")
.replace(Regex("[\\p{Cntrl}]"), "")
.ifEmpty { hexHash }
val currentDateTime = SimpleDateFormat("yyyy-MM-dd_HH-mm-ss", Locale.ENGLISH).format(System.currentTimeMillis())
@ -304,7 +304,7 @@ class MediaDownloader : Feature("MediaDownloader", loadParams = FeatureLoadParam
if ((snapSource == "PUBLIC_USER" || snapSource == "SAVED_STORY") &&
(forceDownload || canAutoDownload("public_stories"))) {
val userDisplayName = (if (paramMap.containsKey("USER_DISPLAY_NAME")) paramMap["USER_DISPLAY_NAME"].toString() else "").replace(
"[^\\x00-\\x7F]".toRegex(),
"[\\p{Cntrl}]".toRegex(),
"")
downloadOperaMedia(provideClientDownloadManager(
@ -336,7 +336,7 @@ class MediaDownloader : Feature("MediaDownloader", loadParams = FeatureLoadParam
}
val storyName = paramMap["STORY_NAME"].toString().replace(
"[^\\x00-\\x7F]".toRegex(),
"[\\p{Cntrl}]".toRegex(),
"")
//get the position of the media in the playlist and the duration
@ -548,4 +548,4 @@ class MediaDownloader : Feature("MediaDownloader", loadParams = FeatureLoadParam
if (messaging.openedConversationUUID == null) return
downloadMessageId(messaging.lastFocusedMessageId, isPreviewMode)
}
}
}

View File

@ -1,6 +1,5 @@
package me.rhunk.snapenhance.features.impl.tweaks
import android.app.AlertDialog
import me.rhunk.snapenhance.config.ConfigProperty
import me.rhunk.snapenhance.data.ContentType
import me.rhunk.snapenhance.data.MessageSender
@ -28,7 +27,7 @@ class GalleryMediaSendOverride : Feature("Gallery Media Send Override", loadPara
}) { param ->
val localMessageContent = MessageContent(param.arg(1))
if (localMessageContent.contentType != ContentType.EXTERNAL_MEDIA) return@hook
//prevent story replies
val messageProtoReader = ProtoReader(localMessageContent.content)
if (messageProtoReader.exists(7)) return@hook
@ -73,4 +72,4 @@ class GalleryMediaSendOverride : Feature("Gallery Media Send Override", loadPara
}
}
}
}
}

View File

@ -11,18 +11,18 @@
android:id="@+id/dialog_latitude"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints=""
android:ems="10"
android:inputType="numberDecimal"
android:hint="Latitude"
android:autofillHints="" />
android:inputType="number|numberDecimal|numberSigned" />
<EditText
android:id="@+id/dialog_longitude"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints=""
android:ems="10"
android:inputType="numberDecimal"
android:hint="Longitude"
android:autofillHints="" />
android:inputType="number|numberDecimal|numberSigned" />
</LinearLayout>