Skip to content

Commit 04c9d66

Browse files
committed
Fix version matching regular expressions
Previously it was possible for these to match versions they were not intended to match. This caused 1.6.10-1.6.13 to match when the intent was to match 1.5.0-1.6.3.
1 parent 22200d5 commit 04c9d66

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

arduino-ci-script.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ function install_ide()
268268
fi
269269

270270
# Determine download file extension
271-
local tgzExtensionVersionsRegex="1.5.[0-9]"
271+
local tgzExtensionVersionsRegex="^1\.5\.[0-9]$"
272272
if [[ "$IDEversion" =~ $tgzExtensionVersionsRegex ]]; then
273273
# The download file extension prior to 1.6.0 is .tgz
274274
local downloadFileExtension="tgz"
@@ -423,12 +423,12 @@ function set_ide_preference()
423423
local -r preferenceString="$1"
424424

425425
# --pref option is only supported by Arduino IDE 1.5.6 and newer
426-
local -r unsupportedPrefOptionVersionsRegex="1.5.[0-5]"
426+
local -r unsupportedPrefOptionVersionsRegex="^1\.5\.[0-5]$"
427427
if ! [[ "$NEWEST_INSTALLED_IDE_VERSION" =~ $unsupportedPrefOptionVersionsRegex ]]; then
428428
install_ide_version "$NEWEST_INSTALLED_IDE_VERSION"
429429

430430
# --save-prefs was added in Arduino IDE 1.5.8
431-
local -r unsupportedSavePrefsOptionVersionsRegex="1.5.[6-7]"
431+
local -r unsupportedSavePrefsOptionVersionsRegex="^1\.5\.[6-7]$"
432432
if ! [[ "$NEWEST_INSTALLED_IDE_VERSION" =~ $unsupportedSavePrefsOptionVersionsRegex ]]; then
433433
# shellcheck disable=SC2086
434434
eval \"${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}/${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER}/${ARDUINO_CI_SCRIPT_ARDUINO_COMMAND}\" --pref "$preferenceString" --save-prefs "$ARDUINO_CI_SCRIPT_VERBOSITY_REDIRECT"
@@ -521,8 +521,8 @@ function install_package()
521521
fi
522522

523523
# Check if the newest installed IDE version supports --install-boards
524-
local -r unsupportedInstallBoardsOptionVersionsRange1regex="1.5.[0-9]"
525-
local -r unsupportedInstallBoardsOptionVersionsRange2regex="1.6.[0-3]"
524+
local -r unsupportedInstallBoardsOptionVersionsRange1regex="^1\.5\.[0-9]$"
525+
local -r unsupportedInstallBoardsOptionVersionsRange2regex="^1\.6\.[0-3]$"
526526
if [[ "$NEWEST_INSTALLED_IDE_VERSION" =~ $unsupportedInstallBoardsOptionVersionsRange1regex || "$NEWEST_INSTALLED_IDE_VERSION" =~ $unsupportedInstallBoardsOptionVersionsRange2regex ]]; then
527527
echo "ERROR: --install-boards option is not supported by the newest version of the Arduino IDE you have installed. You must have Arduino IDE 1.6.4 or newer installed to use this function."
528528
return_handler "$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
@@ -636,8 +636,8 @@ function install_library()
636636
fi
637637

638638
# Check if the newest installed IDE version supports --install-library
639-
local -r unsupportedInstallLibraryOptionVersionsRange1regex="1.5.[0-9]"
640-
local -r unsupportedInstallLibraryOptionVersionsRange2regex="1.6.[0-3]"
639+
local -r unsupportedInstallLibraryOptionVersionsRange1regex="^1\.5\.[0-9]$"
640+
local -r unsupportedInstallLibraryOptionVersionsRange2regex="^1\.6\.[0-3]$"
641641
if [[ "$NEWEST_INSTALLED_IDE_VERSION" =~ $unsupportedInstallLibraryOptionVersionsRange1regex || "$NEWEST_INSTALLED_IDE_VERSION" =~ $unsupportedInstallLibraryOptionVersionsRange2regex ]]; then
642642
echo "ERROR: --install-library option is not supported by the newest version of the Arduino IDE you have installed. You must have Arduino IDE 1.6.4 or newer installed to use this function."
643643
return_handler "$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
@@ -764,8 +764,8 @@ function build_sketch()
764764

765765
# The package_index files installed by some versions of the IDE (1.6.5, 1.6.5) can cause compilation to fail for other versions (1.6.5-r4, 1.6.5-r5). Attempting to install a dummy package ensures that the correct version of those files will be installed before the sketch verification.
766766
# Check if the newest installed IDE version supports --install-boards
767-
local unsupportedInstallBoardsOptionVersionsRange1regex="1.5.[0-9]"
768-
local unsupportedInstallBoardsOptionVersionsRange2regex="1.6.[0-3]"
767+
local unsupportedInstallBoardsOptionVersionsRange1regex="^1\.5\.[0-9]$"
768+
local unsupportedInstallBoardsOptionVersionsRange2regex="^1\.6\.[0-3]$"
769769
if ! [[ "$IDEversion" =~ $unsupportedInstallBoardsOptionVersionsRange1regex || "$IDEversion" =~ $unsupportedInstallBoardsOptionVersionsRange2regex ]]; then
770770
# shellcheck disable=SC2086
771771
eval \"${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}/${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER}/${ARDUINO_CI_SCRIPT_ARDUINO_COMMAND}\" --install-boards arduino:dummy "$ARDUINO_CI_SCRIPT_VERBOSITY_REDIRECT"

0 commit comments

Comments
 (0)