Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions MerlinAU.asp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ input[value="Uninstall"] {
<script language="JavaScript" type="text/javascript">

/**----------------------------**/
/** Last Modified: 2026-May-16 **/
/** Last Modified: 2026-Sep-25 **/
/**----------------------------**/

// Separate variables for shared and AJAX settings //
Expand Down Expand Up @@ -2337,8 +2337,9 @@ function GetConfigSettings()
keyName = tokenStr.substring(0, splitIndex).trim();
keyValue = tokenStr.substring(splitIndex + 1).trim();

// Remove surrounding quotes if present //
if (keyValue.startsWith('"') && keyValue.endsWith('"'))
// Remove surrounding single or double quotes if present //
if ((keyValue.startsWith('"') && keyValue.endsWith('"')) ||
(keyValue.startsWith("'") && keyValue.endsWith("'")))
{ keyValue = keyValue.substring(1, keyValue.length - 1); }

AssignAjaxSetting(keyName, keyValue);
Expand All @@ -2354,8 +2355,9 @@ function GetConfigSettings()
{
keyValue = tokenList[kIndx + 1].trim();

// Remove surrounding quotes if present //
if (keyValue.startsWith('"') && keyValue.endsWith('"'))
// Remove surrounding single or double quotes if present //
if ((keyValue.startsWith('"') && keyValue.endsWith('"')) ||
(keyValue.startsWith("'") && keyValue.endsWith("'")))
{ keyValue = keyValue.substring(1, keyValue.length - 1); }

AssignAjaxSetting(keyName, keyValue);
Expand Down Expand Up @@ -2456,7 +2458,8 @@ function AssignAjaxSetting (keyName, keyValue)
try
{
var decoded = atob(keyValue);
var password = decoded.split(':')[1] || '';
var splitIndex = decoded.indexOf(':');
var password = (splitIndex > 0) ? decoded.slice(splitIndex + 1) : '';
ajax_custom_settings.routerPassword = password;
}
catch (e)
Expand Down
115 changes: 71 additions & 44 deletions MerlinAU.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Project Created: 2023-Oct-01 by @ExtremeFiretop
# Official Co-Author: @Martinski W. since 2023-Nov-01
# Last Modified: 2026-Sep-22
# Last Modified: 2026-Sep-25
#
# MerlinAU™ / MerlinAutoUpdate™
# Official project: https://github.com/ExtremeFiretop/MerlinAutoUpdate-Router
Expand All @@ -20,7 +20,7 @@ set -u

## Set version for each Production Release ##
readonly SCRIPT_VERSION=1.6.9
readonly SCRIPT_VERSTAG="26092216"
readonly SCRIPT_VERSTAG="26092501"
readonly SCRIPT_NAME="MerlinAU"
## Set to "master" for Production Releases ##
SCRIPT_BRANCH="dev"
Expand Down Expand Up @@ -678,8 +678,10 @@ _AcquireMutexFLock_()
##-------------------------------------##
## Added by Martinski W. [2025-Sep-01] ##
##-------------------------------------##
# Intended for BOTH 'grep' & 'sed' cmds
#---------------------------------------#
_EscapeChars_()
{ printf "%s" "$1" | sed 's/[][\/$.*^&-]/\\&/g' ; }
{ printf "%s" "$1" | sed 's/[][\/{}()$|.*^&+-]/\\&/g' ; }

##-------------------------------------##
## Added by Martinski W. [2023-Dec-26] ##
Expand Down Expand Up @@ -1622,16 +1624,19 @@ _InitCustomUserSettings_()
sendEMail_CC_Name="$(Get_Custom_Setting FW_New_Update_EMail_CC_Name)"
sendEMail_CC_Address="$(Get_Custom_Setting FW_New_Update_EMail_CC_Address)"
if [ "$sendEMailFormaType" = "HTML" ]
then isEMailFormatHTML=true
else isEMailFormatHTML=false
then
isEMailFormatHTML=true
else
isEMailFormatHTML=false
sendEMailFormaType="Plain Text"
fi

_SetUp_FW_UpdateZIP_DirectoryPaths_
_SetUp_FW_UpdateLOG_DirectoryPaths_
}

##----------------------------------------##
## Modified by Martinski W. [2025-Jan-05] ##
## Modified by Martinski W. [2025-Sep-25] ##
##----------------------------------------##
Get_Custom_Setting()
{
Expand All @@ -1641,7 +1646,7 @@ Get_Custom_Setting()
local setting_value="" setting_type="$1" default_value="TBD"
[ $# -gt 1 ] && default_value="$2"

if [ -f "$CONFIG_FILE" ]
if [ -s "$CONFIG_FILE" ]
then
case "$setting_type" in
"ROGBuild" | "TUFBuild" | \
Expand All @@ -1655,7 +1660,7 @@ Get_Custom_Setting()
"FW_New_Update_EMail_Notification" | \
"FW_New_Update_Notification_Date" | \
"FW_New_Update_Notification_Vers")
setting_value="$(grep "^${setting_type} " "$CONFIG_FILE" | awk -F ' ' '{print $2}')"
setting_value="$(grep -E "^$setting_type .+" "$CONFIG_FILE" | awk -F' ' '{print $2}')"
;;
"FW_New_Update_Postponement_Days" | \
"FW_New_Update_Changelog_Approval" | \
Expand All @@ -1669,23 +1674,23 @@ Get_Custom_Setting()
"FW_New_Update_EMail_CC_Name" | \
"FW_New_Update_EMail_CC_Address")
grep -q "^${setting_type}=" "$CONFIG_FILE" && \
setting_value="$(grep "^${setting_type}=" "$CONFIG_FILE" | cut -f2- -d'=' | sed "s/['\"]//g")"
setting_value="$(grep -E "^${setting_type}=.+" "$CONFIG_FILE" | cut -f2- -d'=' | sed "s/['\"]//g")"
;;
*)
setting_value="**ERROR**"
;;
esac
if [ -z "$setting_value" ]
then echo "$default_value"
else echo "$setting_value"
else printf '%s\n' "$setting_value"
fi
else
echo "$default_value"
fi
}

##----------------------------------------##
## Modified by maghuro [2026-Sep-24] ##
## Modified by Martinski W. [2026-Sep-25] ##
##----------------------------------------##
Update_Custom_Settings()
{
Expand All @@ -1709,13 +1714,13 @@ Update_Custom_Settings()
"FW_New_Update_EMail_Notification" | \
"FW_New_Update_Notification_Date" | \
"FW_New_Update_Notification_Vers")
if [ -f "$CONFIG_FILE" ]
if [ -s "$CONFIG_FILE" ]
then
if [ "$(grep -c "^$setting_type" "$CONFIG_FILE")" -gt 0 ]
if [ "$(grep -c "^$setting_type " "$CONFIG_FILE")" -gt 0 ]
then
if [ "$setting_value" != "$(grep "^$setting_type" "$CONFIG_FILE" | cut -f2 -d' ')" ]
if [ "$setting_value" != "$(grep -E "^$setting_type .+" "$CONFIG_FILE" | cut -f2 -d' ')" ]
then
fixedVal="$(printf '%s' "$setting_value" | sed 's/[\/&\\]/\\&/g')"
fixedVal="$(_EscapeChars_ "$setting_value")"
sed -i "s/^${setting_type}.*/$setting_type $fixedVal/" "$CONFIG_FILE"
fi
else
Expand All @@ -1736,21 +1741,21 @@ Update_Custom_Settings()
"FW_New_Update_EMail_FormatType" | \
"FW_New_Update_EMail_CC_Name" | \
"FW_New_Update_EMail_CC_Address")
if [ -f "$CONFIG_FILE" ]
if [ -s "$CONFIG_FILE" ]
then
if grep -q "^${setting_type}=" "$CONFIG_FILE"
if grep -qE "^${setting_type}=.*" "$CONFIG_FILE"
then
oldVal="$(grep "^${setting_type}=" "$CONFIG_FILE" | cut -f2- -d'=' | sed "s/['\"]//g")"
oldVal="$(grep -E "^${setting_type}=.+" "$CONFIG_FILE" | cut -f2- -d'=' | sed "s/['\"]//g")"
if [ -z "$oldVal" ] || [ "$oldVal" != "$setting_value" ]
then
fixedVal="$(printf '%s' "$setting_value" | sed 's/[\/&\\]/\\&/g')"
sed -i "s/${setting_type}=.*/${setting_type}=\"${fixedVal}\"/" "$CONFIG_FILE"
fixedVal="$(_EscapeChars_ "$setting_value")"
sed -i "s/${setting_type}=.*/${setting_type}='${fixedVal}'/" "$CONFIG_FILE"
fi
else
echo "$setting_type=\"${setting_value}\"" >> "$CONFIG_FILE"
echo "$setting_type='${setting_value}'" >> "$CONFIG_FILE"
fi
else
echo "$setting_type=\"${setting_value}\"" > "$CONFIG_FILE"
echo "$setting_type='${setting_value}'" > "$CONFIG_FILE"
fi
if [ "$setting_type" = "FW_New_Update_Postponement_Days" ]
then
Expand Down Expand Up @@ -1796,16 +1801,16 @@ Update_Custom_Settings()
;;
*)
# Generic handling for arbitrary settings #
if grep -q "^${setting_type}=" "$CONFIG_FILE"
if grep -qE "^${setting_type}=.*" "$CONFIG_FILE"
then
oldVal="$(grep "^${setting_type}=" "$CONFIG_FILE" | cut -f2- -d'=' | sed "s/['\"]//g")"
oldVal="$(grep -E "^${setting_type}=.+" "$CONFIG_FILE" | cut -f2- -d'=' | sed "s/['\"]//g")"
if [ -z "$oldVal" ] || [ "$oldVal" != "$setting_value" ]
then
fixedVal="$(printf '%s' "$setting_value" | sed 's/[\/&\\]/\\&/g')"
sed -i "s/^${setting_type}=.*/${setting_type}=\"${fixedVal}\"/" "$CONFIG_FILE"
fixedVal="$(_EscapeChars_ "$setting_value")"
sed -i "s/^${setting_type}=.*/${setting_type}='${fixedVal}'/" "$CONFIG_FILE"
fi
else
echo "${setting_type}=\"${setting_value}\"" >> "$CONFIG_FILE"
echo "${setting_type}='${setting_value}'" >> "$CONFIG_FILE"
fi
;;
esac
Expand Down Expand Up @@ -2991,7 +2996,7 @@ _CurlFileDownload_()
}

##----------------------------------------##
## Modified by maghuro [2026-Sep-24] ##
## Modified by maghuro [2026-Sep-24] ##
##----------------------------------------##
_DownloadScriptFiles_()
{
Expand Down Expand Up @@ -3839,8 +3844,11 @@ _CheckEMailConfigFileFromAMTM_()
sendEMailNotificationsFlag="$(Get_Custom_Setting FW_New_Update_EMail_Notification)"
sendEMailFormaType="$(Get_Custom_Setting FW_New_Update_EMail_FormatType)"
if [ "$sendEMailFormaType" = "HTML" ]
then isEMailFormatHTML=true
else isEMailFormatHTML=false
then
isEMailFormatHTML=true
else
isEMailFormatHTML=false
sendEMailFormaType="Plain Text"
fi

if [ -n "$sendEMail_CC_Name" ] && [ "$sendEMail_CC_Name" != "TBD" ] && \
Expand Down Expand Up @@ -11037,7 +11045,7 @@ _DoUnInstallation_()
##-------------------------------------##
_SetEMailFormatType_()
{
local doReturnToMenu
local doReturnToMenu menuFormatStr
local currFormatOpt nextFormatOpt currFormatStr

currFormatOpt="$(Get_Custom_Setting FW_New_Update_EMail_FormatType)"
Expand All @@ -11048,7 +11056,11 @@ _SetEMailFormatType_()
else
nextFormatOpt="$currFormatOpt"
fi
currFormatStr="Current Format: ${GRNct}${currFormatOpt}${NOct}"
if [ "$currFormatOpt" = "HTML" ]
then menuFormatStr="HTML"
else menuFormatStr="Plain Text"
fi
currFormatStr="Current Format: ${GRNct}${menuFormatStr}${NOct}"

doReturnToMenu=false
while true
Expand All @@ -11070,7 +11082,7 @@ _SetEMailFormatType_()
case $userInput in
1) nextFormatOpt="HTML" ; break
;;
2) nextFormatOpt="Plain Text" ; break
2) nextFormatOpt="PlainText" ; break
;;
*) echo ; _InvalidMenuSelection_
;;
Expand Down Expand Up @@ -11101,7 +11113,8 @@ _SetSecondaryEMailAddress_()
local nextCC_NameOpt nextCC_AddrOpt
local currCC_NameStr="Current Name/Alias:"
local currCC_AddrStr="Current Address:"
local clearOptStr="${GRNct}c${NOct}=Clear/Remove Setting"
local invalidChars='[][" *?\\]' #Avoid initial parsing issues#
local clearOptStr="${GRNct}C${NOct}=Clear/Remove Setting"
local doReturnToMenu doClearSetting minCharLen maxCharLen curCharLen

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

userInput=""
minCharLen=10
Expand All @@ -11134,13 +11148,13 @@ _SetSecondaryEMailAddress_()

[ -z "$userInput" ] && break

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

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

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

# Catch invalid chars that may cause parsing errors #
if printf '%s\n' "$userInput" | grep -qE "$invalidChars"
then
printf "\n${REDct}INVALID input.${NOct}\n"
printf "One or more invalid characters were found.\n"
_WaitForEnterKey_
clear
continue
fi

curCharLen="${#userInput}"
if [ "$curCharLen" -lt "$minCharLen" ] || [ "$curCharLen" -gt "$maxCharLen" ]
then
Expand All @@ -11170,9 +11194,9 @@ _SetSecondaryEMailAddress_()
if "$doClearSetting" || \
{ [ -z "$nextCC_AddrOpt" ] && [ -n "$currCC_AddrOpt" ] ; }
then
Update_Custom_Settings FW_New_Update_EMail_CC_Name "TBD"
Update_Custom_Settings FW_New_Update_EMail_CC_Address "TBD"
echo "The secondary email address and associated name/alias were removed successfully."
Update_Custom_Settings FW_New_Update_EMail_CC_Name 'TBD'
Update_Custom_Settings FW_New_Update_EMail_CC_Address 'TBD'
printf "\nThe secondary email address and associated name/alias were removed successfully.\n"
_WaitForEnterKey_ "$advnMenuReturnPromptStr"
return 0
fi
Expand All @@ -11186,6 +11210,7 @@ _SetSecondaryEMailAddress_()
nextCC_NameOpt="$currCC_NameOpt"
currCC_NameStr="$currCC_NameStr ${GRNct}${currCC_NameOpt}${NOct}"
fi
currCC_NameStr="$(echo "$currCC_NameStr" | sed 's/%/%%/g')"

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

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

curCharLen="${#userInput}"
Expand All @@ -11213,7 +11239,8 @@ _SetSecondaryEMailAddress_()
break;
done

if [ "$nextCC_AddrOpt" = "$currCC_AddrOpt" ] && [ "$nextCC_NameOpt" = "$currCC_NameOpt" ]
if [ "$nextCC_AddrOpt" = "$currCC_AddrOpt" ] && \
[ "$nextCC_NameOpt" = "$currCC_NameOpt" ]
then
_RunEMailNotificationTest_ && _WaitForEnterKey_ "$advnMenuReturnPromptStr"
return 0
Expand Down Expand Up @@ -12165,8 +12192,8 @@ _ShowAdvancedOptionsMenu_()
printf "\n ${GRNct}se${NOct}. Set Email Notifications Secondary Address"
if [ -n "$CC_NAME" ] && [ -n "$CC_ADDRESS" ]
then
printf "\n${padStr}[Current Name/Alias: ${GRNct}${CC_NAME}${NOct}]"
printf "\n${padStr}[Current 2nd Address: ${GRNct}${CC_ADDRESS}${NOct}]\n"
printf "\n${padStr}[Current Name/Alias: ${GRNct}%s${NOct}]" "$CC_NAME"
printf "\n${padStr}[Current 2nd Address: ${GRNct}%s${NOct}]\n" "$CC_ADDRESS"
else
echo
fi
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# MerlinAU - AsusWRT-Merlin Firmware Auto Updater

## v1.6.9
## 2026-Sep-22
## 2026-Sep-25

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