Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7b4ef9e

Browse files
author
Akos Kitta
committed
fix: disallow anything but underscore when converting any string to a valid sketch folder name
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 4d45515 commit 7b4ef9e

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

‎arduino-ide-extension/src/common/protocol/sketches-service.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export namespace Sketch {
205205
const validName = candidate
206206
? candidate
207207
.replace(/^[^0-9a-zA-Z]{1}/g, defaultFallbackFirstChar)
208-
.replace(/[^0-9a-zA-Z_\.-]/g, defaultFallbackChar)
208+
.replace(/[^0-9a-zA-Z_]/g, defaultFallbackChar)
209209
.slice(0, 63)
210210
: defaultSketchFolderName;
211211
if (appendTimestampSuffix) {
@@ -233,7 +233,7 @@ export namespace Sketch {
233233
return candidate
234234
? candidate
235235
.replace(/^[^0-9a-zA-Z]{1}/g, defaultFallbackFirstChar)
236-
.replace(/[^0-9a-zA-Z_\.-]/g, defaultFallbackChar)
236+
.replace(/[^0-9a-zA-Z_]/g, defaultFallbackChar)
237237
.slice(0, 36)
238238
: defaultSketchFolderName;
239239
}

‎arduino-ide-extension/src/test/common/sketches-service.test.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ describe('sketch', () => {
107107
['foo bar', 'foo_bar' + epochSuffix],
108108
['.foobar', '0foobar' + epochSuffix],
109109
['-fooBar', '0fooBar' + epochSuffix],
110+
['foobar.', 'foobar_' + epochSuffix],
111+
['fooBar-', 'fooBar_' + epochSuffix],
112+
['fooBar+', 'fooBar_' + epochSuffix],
110113
['vAlid', 'vAlid' + epochSuffix],
111114
].map(([input, expected]) =>
112115
toMapIt(input, expected, (input: string) =>
@@ -118,23 +121,20 @@ describe('sketch', () => {
118121
describe('toValidCloudSketchFolderName', () => {
119122
[
120123
['sketch', 'sketch'],
121-
[
122-
'slash-and-dot-is-ok+but+no+plus.ino',
123-
'slash-and-dot-is-ok_but_no_plus.ino',
124-
],
124+
['only_underscore-is+ok.ino', 'only_underscore_is_ok_ino'],
125125
['regex++', 'regex__'],
126-
['dots...', 'dots...'],
127-
['.dots...', '0dots...'],
128-
['-dashes---', '0dashes---'],
126+
['dots...', 'dots___'],
127+
['.dots...', '0dots___'],
128+
['-dashes---', '0dashes___'],
129129
['_underscore___', '0underscore___'],
130130
['No Spaces', 'No_Spaces'],
131131
['_startsWithUnderscore', '0startsWithUnderscore'],
132-
['Invalid+Char.ino', 'Invalid_Char.ino'],
132+
['Invalid+Char.ino', 'Invalid_Char_ino'],
133133
['', 'sketch'],
134134
['/', '0'],
135135
[
136-
'//////////////////////////////////////-/',
137-
'0___________________________________',
136+
'/-1////////////////////+//////////////-/',
137+
'0_1_________________________________',
138138
],
139139
['//trash/', '0_trash_'],
140140
[

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /