From a81ef58501dcb89eb2a3d77efd393a1b766a5160 Mon Sep 17 00:00:00 2001 From: fukiame Date: Sat, 7 Feb 2026 22:08:49 +0700 Subject: [PATCH] [1/2] feat: {parse.sh, common.sh}: "y2k" support parse whole version, avoid potential patches leak when, for example, 6.5.0 lands get_mb_ver now must have an argument, for any usage outside of what ive grep'd, to retain the previous behavior, pass '2' Signed-off-by: fukiame --- MBCPApp/common.sh | 3 ++- MBCPApp/parse.sh | 30 ++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/MBCPApp/common.sh b/MBCPApp/common.sh index 945a3ae..f5af0e2 100644 --- a/MBCPApp/common.sh +++ b/MBCPApp/common.sh @@ -118,10 +118,11 @@ pblock() { } get_mb_ver() { + [ -z "$1" ] && return 420 a="$(grep -m1 'android:versionName' "$DIRPATH"/mbapk/mbapk_unpacked/AndroidManifest.xml | tr ' ' '\n' | grep -m1 'android:versionName')" a="$(bb_split "$a" '=' '1')" a="$(strip_all "$a" '"')" - bb_split "$a" '.' '2' + bb_split "$a" '.' "$1" } good() { diff --git a/MBCPApp/parse.sh b/MBCPApp/parse.sh index f91aa40..3ab9f2f 100644 --- a/MBCPApp/parse.sh +++ b/MBCPApp/parse.sh @@ -77,12 +77,38 @@ for f in patches/*.sh ; do continue } [ -n "$minver" ] && { - [ "$(get_mb_ver)" -gt "$minver" ] || { + chk="${minver//[^.]}" + [ "${#chk}" -ne 2 ] && { + warn "[parser] skipping [$pname] with malformed minver" + continue + } + + minmajor="$(bb_split "$minver" '.' '0')" + minminor="$(bb_split "$minver" '.' '1')" + minpatch="$(bb_split "$minver" '.' '2')" + + [ [ "$(get_mb_ver '0')" -ge "$minmajor" ] && \ + [ "$(get_mb_ver '1')" -ge "$minminor" ] && \ + [ "$(get_mb_ver '2')" -gt "$minpatch" ] \ + ] || { info "[parser] skipping [$pname] as current version is lower than patch version clamp" continue ; } } || : [ -n "$maxver" ] && { - [ "$(get_mb_ver)" -lt "$maxver" ] || { + chk="${minver//[^.]}" + [ "${#chk}" -ne 2 ] && { + warn "[parser] skipping [$pname] with malformed maxver" + continue + } + + maxmajor="$(bb_split "$maxver" '.' '0')" + maxminor="$(bb_split "$maxver" '.' '1')" + maxpatch="$(bb_split "$maxver" '.' '2')" + + [ [ "$(get_mb_ver '0')" -le "$maxmajor" ] && \ + [ "$(get_mb_ver '1')" -le "$maxminor" ] && \ + [ "$(get_mb_ver '2')" -lt "$maxpatch" ] \ + ] || { info "[parser] skipping [$pname] as current version is higher than patch version clamp" continue ; } } || :