Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix option parser: Match any character as option name #1481

Merged
merged 2 commits into from
Oct 18, 2018
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
4 changes: 2 additions & 2 deletions packages/arduino-cli/src/optionParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export const getLines = R.compose(

const menuRegExp = /^menu\./;

const optionNameRegExp = /^menu\.([a-zA-Z0-9_]+)=([a-zA-Z0-9-_ ]+)$/;
const optionNameRegExp = /^menu\.([a-zA-Z0-9_]+)=(.+)$/;

const boardOptionRegExp = /^([a-zA-Z0-9_]+)\.menu\.([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)=([a-zA-Z0-9-_ ()]+)$/;
const boardOptionRegExp = /^([a-zA-Z0-9_]+)\.menu\.([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)=(.+)$/;

const osRegExp = /(linux|macosx|windows)/;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#### JUST A PART OF BOARDS.TXT FILE FROM ESP8266 PACKAGE
#### SOME OPTIONS WAS REMOVED TO MINIFY FIXTURE
#### A PART OF BOARDS.TXT FILE FROM ESP8266 PACKAGE
#### WITH SOME CHANGES: MENU AND OPTION NAMES
#### NOW CONTAINS SPECIAL CHARACTERS AND CYRILLIC SYMBOLS
#### TO MAKE SURE IN THE UNIT TESTS IT WILL WORK FINE
#### WITH ANY PACKAGE.
####
#### ONLY FOR TESTS!

#
# Do not create pull-requests for this file only, CI will not accept them.
# You *must* edit/modify/run boards.txt.py to regenerate boards.txt.
# All modified files after running with option "--allgen" must be included in the pull-request.
#

menu.UploadSpeed=Upload Speed
menu.CpuFrequency=CPU Frequency
menu.UploadSpeed=Uplo@d Speed (Скорость загрузки)
menu.CpuFrequency=CPU Frequency 123,-_[]():@we$ome

##############################################################
generic.name=Generic ESP8266 Module
Expand All @@ -26,7 +24,7 @@ generic.build.variant=generic
generic.build.spiffs_pagesize=256
generic.build.debug_port=
generic.build.debug_level=
generic.menu.CpuFrequency.80=80 MHz
generic.menu.CpuFrequency.80=80 MHz (!@#$$%^&*()[]_-+,./)
generic.menu.CpuFrequency.80.build.f_cpu=80000000L
generic.menu.CpuFrequency.160=160 MHz
generic.menu.CpuFrequency.160.build.f_cpu=160000000L
Expand Down Expand Up @@ -64,7 +62,7 @@ wifi_slot.build.core=esp8266
wifi_slot.build.spiffs_pagesize=256
wifi_slot.build.debug_port=
wifi_slot.build.debug_level=
wifi_slot.menu.CpuFrequency.80=80 MHz
wifi_slot.menu.CpuFrequency.80=80 MHz (!@#$$%^&*()[]_-+,./)
wifi_slot.menu.CpuFrequency.80.build.f_cpu=80000000L
wifi_slot.menu.CpuFrequency.160=160 MHz
wifi_slot.menu.CpuFrequency.160.build.f_cpu=160000000L
Expand Down
12 changes: 6 additions & 6 deletions packages/arduino-cli/test/optionParser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const fixtureDir = path.resolve(__dirname, 'fixtures');
// =============================================================================

const espOptionNames = {
UploadSpeed: 'Upload Speed',
CpuFrequency: 'CPU Frequency',
UploadSpeed: 'Uplo@d Speed (Скорость загрузки)',
CpuFrequency: 'CPU Frequency 123,-_[]():@we$ome',
};

const espOptions = {
Expand All @@ -47,7 +47,7 @@ const espOptions = {
],
CpuFrequency: [
{
name: '80 MHz',
name: '80 MHz (!@#$$%^&*()[]_-+,./)',
value: '80',
},
{
Expand All @@ -58,7 +58,7 @@ const espOptions = {
};

const uploadSpeedOptions = {
optionName: 'Upload Speed',
optionName: 'Uplo@d Speed (Скорость загрузки)',
optionId: 'UploadSpeed',
values: [
{
Expand All @@ -80,11 +80,11 @@ const uploadSpeedOptions = {
],
};
const cpuFrequencyOptions = {
optionName: 'CPU Frequency',
optionName: 'CPU Frequency 123,-_[]():@we$ome',
optionId: 'CpuFrequency',
values: [
{
name: '80 MHz',
name: '80 MHz (!@#$$%^&*()[]_-+,./)',
value: '80',
},
{
Expand Down