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 d304922

Browse files
author
Akos Kitta
committed
fix: escaped regex chars in pattern
Closes #1600 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 8a85b5c commit d304922

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

‎arduino-ide-extension/package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"@types/deepmerge": "^2.2.0",
4646
"@types/glob": "^7.2.0",
4747
"@types/google-protobuf": "^3.7.2",
48-
"@types/is-valid-path": "^0.1.0",
4948
"@types/js-yaml": "^3.12.2",
5049
"@types/keytar": "^4.4.0",
5150
"@types/lodash.debounce": "^4.0.6",

‎arduino-ide-extension/src/electron-main/theia/electron-main-application.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727
CLOSE_PLOTTER_WINDOW,
2828
SHOW_PLOTTER_WINDOW,
2929
} from '../../common/ipc-communication';
30-
import isValidPath = require('is-valid-path');
3130

3231
app.commandLine.appendSwitch('disable-http-cache');
3332

@@ -205,9 +204,6 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
205204
maybePath: string,
206205
cwd: string
207206
): Promise<string | undefined> {
208-
if (!isValidPath(maybePath)) {
209-
return undefined;
210-
}
211207
if (isAbsolute(maybePath)) {
212208
return maybePath;
213209
}

‎arduino-ide-extension/src/node/sketches-service-impl.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
LoadSketchRequest,
2727
} from './cli-protocol/cc/arduino/cli/commands/v1/commands_pb';
2828
import { Deferred } from '@theia/core/lib/common/promise-util';
29+
import { escapeRegExpCharacters } from '@theia/core/lib/common/strings';
2930
import { ServiceError } from './service-error';
3031
import {
3132
IsTempSketch,
@@ -157,7 +158,7 @@ export class SketchesServiceImpl
157158
const sketchName = segments[segments.length - 2];
158159
const sketchFilename = segments[segments.length - 1];
159160
const sketchFileExtension = segments[segments.length - 1].replace(
160-
new RegExp(sketchName),
161+
new RegExp(escapeRegExpCharacters(sketchName)),
161162
''
162163
);
163164
if (sketchFileExtension !== '.ino' && sketchFileExtension !== '.pde') {
@@ -733,10 +734,12 @@ async function isInvalidSketchNameError(
733734
if (ino) {
734735
const sketchFolderPath = path.dirname(requestSketchPath);
735736
const sketchName = path.basename(sketchFolderPath);
736-
const pattern = `${invalidSketchNameErrorRegExpPrefix}${path.join(
737-
sketchFolderPath,
738-
`${sketchName}.ino`
739-
)}`.replace(/\\/g, '\\\\'); // make windows path separator with \\ to have a valid regexp.
737+
const pattern = escapeRegExpCharacters(
738+
`${invalidSketchNameErrorRegExpPrefix}${path.join(
739+
sketchFolderPath,
740+
`${sketchName}.ino`
741+
)}`
742+
);
740743
if (new RegExp(pattern, 'i').test(cliErr.details)) {
741744
try {
742745
await fs.access(requestSketchPath);

‎yarn.lock‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3118,11 +3118,6 @@
31183118
resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz#0ea7b61496902b95890dc4c3a116b60cb8dae812"
31193119
integrity sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ==
31203120

3121-
"@types/is-valid-path@^0.1.0":
3122-
version "0.1.0"
3123-
resolved "https://registry.yarnpkg.com/@types/is-valid-path/-/is-valid-path-0.1.0.tgz#d5c6e96801303112c9626d44268c6fabc72d272f"
3124-
integrity sha512-2ontWtpN8O2nf5S7EjDDJ0DwrRa2t7wmS3Wmo322yWYG6yFBYC1QCaLhz4Iz+mzJy8Kf4zP5yVyEd1ANPDmOFQ==
3125-
31263121
"@types/js-yaml@^3.12.2":
31273122
version "3.12.7"
31283123
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-3.12.7.tgz#330c5d97a3500e9c903210d6e49f02964af04a0e"

0 commit comments

Comments
(0)

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