Skip to content

Commit

Permalink
fix: allow spaces in firmware names (zwave-js#1702)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone authored Feb 10, 2021
1 parent a04225e commit 4944c95
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@
"config": "ts-node maintenance/importConfig.ts",
"docs": "docsify serve docs",
"docs:generate": "ts-node -P maintenance/tsconfig.json maintenance/generateTypedDocs.ts",
"perf": "ts-node test/valuedb-perf.ts"
"test:perf": "ts-node test/valuedb-perf.ts",
"test:firmware": "ts-node test/firmware-extraction.ts"
},
"readme": "README.md",
"husky": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/util/firmware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function extractFirmwareAeotec(data: Buffer): Firmware {
firmwareNameBytes.indexOf(0, firmwareNameOffset),
)
.toString("utf8");
if (!/^[a-zA-Z0-9_]+$/.test(firmwareName)) {
if (!/^[a-zA-Z0-9_ -]+$/.test(firmwareName)) {
throw new ZWaveError(
"This does not appear to be a valid Aeotec updater (invalid firmware name)!",
ZWaveErrorCodes.Argument_Invalid,
Expand Down
9 changes: 9 additions & 0 deletions test/firmware-extraction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { extractFirmware, guessFirmwareFileFormat } from "@zwave-js/core";
import * as fs from "fs-extra";

void (async () => {
const filename = process.argv[2];
const data = await fs.readFile(filename);
const format = guessFirmwareFileFormat(filename, data);
extractFirmware(data, format);
})();

0 comments on commit 4944c95

Please sign in to comment.