Skip to content

Commit 4e06a48

Browse files
Merge pull request #614 from Martinski4GitHub/dev
Fixes and Code Improvements
2 parents 4e779db + a2fd184 commit 4e06a48

3 files changed

Lines changed: 81 additions & 51 deletions

File tree

‎MerlinAU.asp‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ input[value="Uninstall"] {
304304
<script language="JavaScript" type="text/javascript">
305305
306306
/**----------------------------**/
307-
/** Last Modified: 2026-May-16 **/
307+
/** Last Modified: 2026-Sep-25 **/
308308
/**----------------------------**/
309309
310310
// Separate variables for shared and AJAX settings //
@@ -2337,8 +2337,9 @@ function GetConfigSettings()
23372337
keyName = tokenStr.substring(0, splitIndex).trim();
23382338
keyValue = tokenStr.substring(splitIndex + 1).trim();
23392339
2340-
// Remove surrounding quotes if present //
2341-
if (keyValue.startsWith('"') && keyValue.endsWith('"'))
2340+
// Remove surrounding single or double quotes if present //
2341+
if ((keyValue.startsWith('"') && keyValue.endsWith('"')) ||
2342+
(keyValue.startsWith("'") && keyValue.endsWith("'")))
23422343
{ keyValue = keyValue.substring(1, keyValue.length - 1); }
23432344
23442345
AssignAjaxSetting(keyName, keyValue);
@@ -2354,8 +2355,9 @@ function GetConfigSettings()
23542355
{
23552356
keyValue = tokenList[kIndx + 1].trim();
23562357
2357-
// Remove surrounding quotes if present //
2358-
if (keyValue.startsWith('"') && keyValue.endsWith('"'))
2358+
// Remove surrounding single or double quotes if present //
2359+
if ((keyValue.startsWith('"') && keyValue.endsWith('"')) ||
2360+
(keyValue.startsWith("'") && keyValue.endsWith("'")))
23592361
{ keyValue = keyValue.substring(1, keyValue.length - 1); }
23602362
23612363
AssignAjaxSetting(keyName, keyValue);
@@ -2456,7 +2458,8 @@ function AssignAjaxSetting (keyName, keyValue)
24562458
try
24572459
{
24582460
var decoded = atob(keyValue);
2459-
var password = decoded.split(':')[1] || '';
2461+
var splitIndex = decoded.indexOf(':');
2462+
var password = (splitIndex > 0) ? decoded.slice(splitIndex + 1) : '';
24602463
ajax_custom_settings.routerPassword = password;
24612464
}
24622465
catch (e)

‎MerlinAU.sh‎

Lines changed: 71 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Project Created: 2023-Oct-01 by @ExtremeFiretop
66
# Official Co-Author: @Martinski W. since 2023-Nov-01
7-
# Last Modified: 2026-Sep-22
7+
# Last Modified: 2026-Sep-25
88
#
99
# MerlinAU™ / MerlinAutoUpdate™
1010
# Official project: https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router
@@ -20,7 +20,7 @@ set -u
2020

2121
## Set version for each Production Release ##
2222
readonly SCRIPT_VERSION=1.6.9
23-
readonly SCRIPT_VERSTAG="26092216"
23+
readonly SCRIPT_VERSTAG="26092501"
2424
readonly SCRIPT_NAME="MerlinAU"
2525
## Set to "master" for Production Releases ##
2626
SCRIPT_BRANCH="dev"
@@ -678,8 +678,10 @@ _AcquireMutexFLock_()
678678
##-------------------------------------##
679679
## Added by Martinski W. [2025-Sep-01] ##
680680
##-------------------------------------##
681+
# Intended for BOTH 'grep' & 'sed' cmds
682+
#---------------------------------------#
681683
_EscapeChars_()
682-
{ printf "%s" "$1" | sed 's/[][\/$.*^&-]/\\&/g' ; }
684+
{ printf "%s" "$1" | sed 's/[][\/{}()$|.*^&+-]/\\&/g' ; }
683685

684686
##-------------------------------------##
685687
## Added by Martinski W. [2023-Dec-26] ##
@@ -1622,16 +1624,19 @@ _InitCustomUserSettings_()
16221624
sendEMail_CC_Name="$(Get_Custom_Setting FW_New_Update_EMail_CC_Name)"
16231625
sendEMail_CC_Address="$(Get_Custom_Setting FW_New_Update_EMail_CC_Address)"
16241626
if [ "$sendEMailFormaType" = "HTML" ]
1625-
then isEMailFormatHTML=true
1626-
else isEMailFormatHTML=false
1627+
then
1628+
isEMailFormatHTML=true
1629+
else
1630+
isEMailFormatHTML=false
1631+
sendEMailFormaType="Plain Text"
16271632
fi
16281633

16291634
_SetUp_FW_UpdateZIP_DirectoryPaths_
16301635
_SetUp_FW_UpdateLOG_DirectoryPaths_
16311636
}
16321637

16331638
##----------------------------------------##
1634-
## Modified by Martinski W. [2025-Jan-05] ##
1639+
## Modified by Martinski W. [2025-Sep-25] ##
16351640
##----------------------------------------##
16361641
Get_Custom_Setting()
16371642
{
@@ -1641,7 +1646,7 @@ Get_Custom_Setting()
16411646
local setting_value="" setting_type="$1" default_value="TBD"
16421647
[ $# -gt 1 ] && default_value="$2"
16431648

1644-
if [ -f "$CONFIG_FILE" ]
1649+
if [ -s "$CONFIG_FILE" ]
16451650
then
16461651
case "$setting_type" in
16471652
"ROGBuild" | "TUFBuild" | \
@@ -1655,7 +1660,7 @@ Get_Custom_Setting()
16551660
"FW_New_Update_EMail_Notification" | \
16561661
"FW_New_Update_Notification_Date" | \
16571662
"FW_New_Update_Notification_Vers")
1658-
setting_value="$(grep "^${setting_type} " "$CONFIG_FILE" | awk -F ' ' '{print $2}')"
1663+
setting_value="$(grep -E "^$setting_type .+" "$CONFIG_FILE" | awk -F' ' '{print $2}')"
16591664
;;
16601665
"FW_New_Update_Postponement_Days" | \
16611666
"FW_New_Update_Changelog_Approval" | \
@@ -1669,23 +1674,23 @@ Get_Custom_Setting()
16691674
"FW_New_Update_EMail_CC_Name" | \
16701675
"FW_New_Update_EMail_CC_Address")
16711676
grep -q "^${setting_type}=" "$CONFIG_FILE" && \
1672-
setting_value="$(grep "^${setting_type}=" "$CONFIG_FILE" | cut -f2- -d'=' | sed "s/['\"]//g")"
1677+
setting_value="$(grep -E "^${setting_type}=.+" "$CONFIG_FILE" | cut -f2- -d'=' | sed "s/['\"]//g")"
16731678
;;
16741679
*)
16751680
setting_value="**ERROR**"
16761681
;;
16771682
esac
16781683
if [ -z "$setting_value" ]
16791684
then echo "$default_value"
1680-
else echo "$setting_value"
1685+
else printf '%s\n' "$setting_value"
16811686
fi
16821687
else
16831688
echo "$default_value"
16841689
fi
16851690
}
16861691

16871692
##----------------------------------------##
1688-
## Modified by maghuro [2026-Sep-24] ##
1693+
## Modified by Martinski W. [2026-Sep-25] ##
16891694
##----------------------------------------##
16901695
Update_Custom_Settings()
16911696
{
@@ -1709,13 +1714,13 @@ Update_Custom_Settings()
17091714
"FW_New_Update_EMail_Notification" | \
17101715
"FW_New_Update_Notification_Date" | \
17111716
"FW_New_Update_Notification_Vers")
1712-
if [ -f "$CONFIG_FILE" ]
1717+
if [ -s "$CONFIG_FILE" ]
17131718
then
1714-
if [ "$(grep -c "^$setting_type" "$CONFIG_FILE")" -gt 0 ]
1719+
if [ "$(grep -c "^$setting_type " "$CONFIG_FILE")" -gt 0 ]
17151720
then
1716-
if [ "$setting_value" != "$(grep "^$setting_type" "$CONFIG_FILE" | cut -f2 -d' ')" ]
1721+
if [ "$setting_value" != "$(grep -E "^$setting_type .+" "$CONFIG_FILE" | cut -f2 -d' ')" ]
17171722
then
1718-
fixedVal="$(printf '%s' "$setting_value" | sed 's/[\/&\\]/\\&/g')"
1723+
fixedVal="$(_EscapeChars_ "$setting_value")"
17191724
sed -i "s/^${setting_type}.*/$setting_type $fixedVal/" "$CONFIG_FILE"
17201725
fi
17211726
else
@@ -1736,21 +1741,21 @@ Update_Custom_Settings()
17361741
"FW_New_Update_EMail_FormatType" | \
17371742
"FW_New_Update_EMail_CC_Name" | \
17381743
"FW_New_Update_EMail_CC_Address")
1739-
if [ -f "$CONFIG_FILE" ]
1744+
if [ -s "$CONFIG_FILE" ]
17401745
then
1741-
if grep -q "^${setting_type}=" "$CONFIG_FILE"
1746+
if grep -qE "^${setting_type}=.*" "$CONFIG_FILE"
17421747
then
1743-
oldVal="$(grep "^${setting_type}=" "$CONFIG_FILE" | cut -f2- -d'=' | sed "s/['\"]//g")"
1748+
oldVal="$(grep -E "^${setting_type}=.+" "$CONFIG_FILE" | cut -f2- -d'=' | sed "s/['\"]//g")"
17441749
if [ -z "$oldVal" ] || [ "$oldVal" != "$setting_value" ]
17451750
then
1746-
fixedVal="$(printf '%s' "$setting_value" | sed 's/[\/&\\]/\\&/g')"
1747-
sed -i "s/${setting_type}=.*/${setting_type}=\"${fixedVal}\"/" "$CONFIG_FILE"
1751+
fixedVal="$(_EscapeChars_ "$setting_value")"
1752+
sed -i "s/${setting_type}=.*/${setting_type}='${fixedVal}'/" "$CONFIG_FILE"
17481753
fi
17491754
else
1750-
echo "$setting_type=\"${setting_value}\"" >> "$CONFIG_FILE"
1755+
echo "$setting_type='${setting_value}'" >> "$CONFIG_FILE"
17511756
fi
17521757
else
1753-
echo "$setting_type=\"${setting_value}\"" > "$CONFIG_FILE"
1758+
echo "$setting_type='${setting_value}'" > "$CONFIG_FILE"
17541759
fi
17551760
if [ "$setting_type" = "FW_New_Update_Postponement_Days" ]
17561761
then
@@ -1796,16 +1801,16 @@ Update_Custom_Settings()
17961801
;;
17971802
*)
17981803
# Generic handling for arbitrary settings #
1799-
if grep -q "^${setting_type}=" "$CONFIG_FILE"
1804+
if grep -qE "^${setting_type}=.*" "$CONFIG_FILE"
18001805
then
1801-
oldVal="$(grep "^${setting_type}=" "$CONFIG_FILE" | cut -f2- -d'=' | sed "s/['\"]//g")"
1806+
oldVal="$(grep -E "^${setting_type}=.+" "$CONFIG_FILE" | cut -f2- -d'=' | sed "s/['\"]//g")"
18021807
if [ -z "$oldVal" ] || [ "$oldVal" != "$setting_value" ]
18031808
then
1804-
fixedVal="$(printf '%s' "$setting_value" | sed 's/[\/&\\]/\\&/g')"
1805-
sed -i "s/^${setting_type}=.*/${setting_type}=\"${fixedVal}\"/" "$CONFIG_FILE"
1809+
fixedVal="$(_EscapeChars_ "$setting_value")"
1810+
sed -i "s/^${setting_type}=.*/${setting_type}='${fixedVal}'/" "$CONFIG_FILE"
18061811
fi
18071812
else
1808-
echo "${setting_type}=\"${setting_value}\"" >> "$CONFIG_FILE"
1813+
echo "${setting_type}='${setting_value}'" >> "$CONFIG_FILE"
18091814
fi
18101815
;;
18111816
esac
@@ -2991,7 +2996,7 @@ _CurlFileDownload_()
29912996
}
29922997

29932998
##----------------------------------------##
2994-
## Modified by maghuro [2026-Sep-24] ##
2999+
## Modified by maghuro [2026-Sep-24] ##
29953000
##----------------------------------------##
29963001
_DownloadScriptFiles_()
29973002
{
@@ -3839,8 +3844,11 @@ _CheckEMailConfigFileFromAMTM_()
38393844
sendEMailNotificationsFlag="$(Get_Custom_Setting FW_New_Update_EMail_Notification)"
38403845
sendEMailFormaType="$(Get_Custom_Setting FW_New_Update_EMail_FormatType)"
38413846
if [ "$sendEMailFormaType" = "HTML" ]
3842-
then isEMailFormatHTML=true
3843-
else isEMailFormatHTML=false
3847+
then
3848+
isEMailFormatHTML=true
3849+
else
3850+
isEMailFormatHTML=false
3851+
sendEMailFormaType="Plain Text"
38443852
fi
38453853

38463854
if [ -n "$sendEMail_CC_Name" ] && [ "$sendEMail_CC_Name" != "TBD" ] && \
@@ -11037,7 +11045,7 @@ _DoUnInstallation_()
1103711045
##-------------------------------------##
1103811046
_SetEMailFormatType_()
1103911047
{
11040-
local doReturnToMenu
11048+
local doReturnToMenu menuFormatStr
1104111049
local currFormatOpt nextFormatOpt currFormatStr
1104211050

1104311051
currFormatOpt="$(Get_Custom_Setting FW_New_Update_EMail_FormatType)"
@@ -11048,7 +11056,11 @@ _SetEMailFormatType_()
1104811056
else
1104911057
nextFormatOpt="$currFormatOpt"
1105011058
fi
11051-
currFormatStr="Current Format: ${GRNct}${currFormatOpt}${NOct}"
11059+
if [ "$currFormatOpt" = "HTML" ]
11060+
then menuFormatStr="HTML"
11061+
else menuFormatStr="Plain Text"
11062+
fi
11063+
currFormatStr="Current Format: ${GRNct}${menuFormatStr}${NOct}"
1105211064

1105311065
doReturnToMenu=false
1105411066
while true
@@ -11070,7 +11082,7 @@ _SetEMailFormatType_()
1107011082
case $userInput in
1107111083
1) nextFormatOpt="HTML" ; break
1107211084
;;
11073-
2) nextFormatOpt="Plain Text" ; break
11085+
2) nextFormatOpt="PlainText" ; break
1107411086
;;
1107511087
*) echo ; _InvalidMenuSelection_
1107611088
;;
@@ -11101,7 +11113,8 @@ _SetSecondaryEMailAddress_()
1110111113
local nextCC_NameOpt nextCC_AddrOpt
1110211114
local currCC_NameStr="Current Name/Alias:"
1110311115
local currCC_AddrStr="Current Address:"
11104-
local clearOptStr="${GRNct}c${NOct}=Clear/Remove Setting"
11116+
local invalidChars='[][" *?\\]' #Avoid initial parsing issues#
11117+
local clearOptStr="${GRNct}C${NOct}=Clear/Remove Setting"
1110511118
local doReturnToMenu doClearSetting minCharLen maxCharLen curCharLen
1110611119

1110711120
currCC_NameOpt="$(Get_Custom_Setting FW_New_Update_EMail_CC_Name)"
@@ -11115,6 +11128,7 @@ _SetSecondaryEMailAddress_()
1111511128
nextCC_AddrOpt="$currCC_AddrOpt"
1111611129
currCC_AddrStr="$currCC_AddrStr ${GRNct}${currCC_AddrOpt}${NOct}"
1111711130
fi
11131+
currCC_AddrStr="$(echo "$currCC_AddrStr" | sed 's/%/%%/g')"
1111811132

1111911133
userInput=""
1112011134
minCharLen=10
@@ -11134,13 +11148,13 @@ _SetSecondaryEMailAddress_()
1113411148

1113511149
[ -z "$userInput" ] && break
1113611150

11137-
if echo "$userInput" | grep -qE "^(e|exit|Exit)$"
11151+
if printf '%s\n' "$userInput" | grep -qE "^(e|exit|Exit)$"
1113811152
then doReturnToMenu=true ; break ; fi
1113911153

11140-
if echo "$userInput" | grep -qE "^(c|C)$"
11154+
if printf '%s\n' "$userInput" | grep -qE "^(c|C)$"
1114111155
then doClearSetting=true ; break ; fi
1114211156

11143-
if ! echo "$userInput" | grep -qE ".+[@].+"
11157+
if ! printf '%s\n' "$userInput" | grep -qE ".+[@].+"
1114411158
then
1114511159
printf "\n${REDct}INVALID input.${NOct} "
1114611160
printf "No ampersand character [${GRNct}@${NOct}] is found.\n"
@@ -11149,6 +11163,16 @@ _SetSecondaryEMailAddress_()
1114911163
continue
1115011164
fi
1115111165

11166+
# Catch invalid chars that may cause parsing errors #
11167+
if printf '%s\n' "$userInput" | grep -qE "$invalidChars"
11168+
then
11169+
printf "\n${REDct}INVALID input.${NOct}\n"
11170+
printf "One or more invalid characters were found.\n"
11171+
_WaitForEnterKey_
11172+
clear
11173+
continue
11174+
fi
11175+
1115211176
curCharLen="${#userInput}"
1115311177
if [ "$curCharLen" -lt "$minCharLen" ] || [ "$curCharLen" -gt "$maxCharLen" ]
1115411178
then
@@ -11170,9 +11194,9 @@ _SetSecondaryEMailAddress_()
1117011194
if "$doClearSetting" || \
1117111195
{ [ -z "$nextCC_AddrOpt" ] && [ -n "$currCC_AddrOpt" ] ; }
1117211196
then
11173-
Update_Custom_Settings FW_New_Update_EMail_CC_Name "TBD"
11174-
Update_Custom_Settings FW_New_Update_EMail_CC_Address "TBD"
11175-
echo "The secondary email address and associated name/alias were removed successfully."
11197+
Update_Custom_Settings FW_New_Update_EMail_CC_Name 'TBD'
11198+
Update_Custom_Settings FW_New_Update_EMail_CC_Address 'TBD'
11199+
printf "\nThe secondary email address and associated name/alias were removed successfully.\n"
1117611200
_WaitForEnterKey_ "$advnMenuReturnPromptStr"
1117711201
return 0
1117811202
fi
@@ -11186,6 +11210,7 @@ _SetSecondaryEMailAddress_()
1118611210
nextCC_NameOpt="$currCC_NameOpt"
1118711211
currCC_NameStr="$currCC_NameStr ${GRNct}${currCC_NameOpt}${NOct}"
1118811212
fi
11213+
currCC_NameStr="$(echo "$currCC_NameStr" | sed 's/%/%%/g')"
1118911214

1119011215
userInput=""
1119111216
minCharLen=6
@@ -11198,7 +11223,8 @@ _SetSecondaryEMailAddress_()
1119811223
printf "[${theADExitStr}]\n[${currCC_NameStr}]: "
1119911224
read -r userInput
1120011225

11201-
if [ -z "$userInput" ] || echo "$userInput" | grep -qE "^(e|exit|Exit)$"
11226+
if [ -z "$userInput" ] || \
11227+
printf '%s\n' "$userInput" | grep -qE "^(e|exit|Exit)$"
1120211228
then doReturnToMenu=true ; break ; fi
1120311229

1120411230
curCharLen="${#userInput}"
@@ -11213,7 +11239,8 @@ _SetSecondaryEMailAddress_()
1121311239
break;
1121411240
done
1121511241

11216-
if [ "$nextCC_AddrOpt" = "$currCC_AddrOpt" ] && [ "$nextCC_NameOpt" = "$currCC_NameOpt" ]
11242+
if [ "$nextCC_AddrOpt" = "$currCC_AddrOpt" ] && \
11243+
[ "$nextCC_NameOpt" = "$currCC_NameOpt" ]
1121711244
then
1121811245
_RunEMailNotificationTest_ && _WaitForEnterKey_ "$advnMenuReturnPromptStr"
1121911246
return 0
@@ -12165,8 +12192,8 @@ _ShowAdvancedOptionsMenu_()
1216512192
printf "\n ${GRNct}se${NOct}. Set Email Notifications Secondary Address"
1216612193
if [ -n "$CC_NAME" ] && [ -n "$CC_ADDRESS" ]
1216712194
then
12168-
printf "\n${padStr}[Current Name/Alias: ${GRNct}${CC_NAME}${NOct}]"
12169-
printf "\n${padStr}[Current 2nd Address: ${GRNct}${CC_ADDRESS}${NOct}]\n"
12195+
printf "\n${padStr}[Current Name/Alias: ${GRNct}%s${NOct}]" "$CC_NAME"
12196+
printf "\n${padStr}[Current 2nd Address: ${GRNct}%s${NOct}]\n" "$CC_ADDRESS"
1217012197
else
1217112198
echo
1217212199
fi

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# MerlinAU - AsusWRT-Merlin Firmware Auto Updater
22

33
## v1.6.9
4-
## 2026-Sep-22
4+
## 2026-Sep-25
55

66
## WebUI:
77
<img width="775" height="1640" alt="image" src="https://github.com/user-attachments/assets/846f889b-b39f-4ffe-a37a-8892ad9b2f7f" />

0 commit comments

Comments
 (0)