Skip to content

Commit

Permalink
fix(steps): sanitize asset bundle file name
Browse files Browse the repository at this point in the history
  • Loading branch information
toverux committed Oct 25, 2017
1 parent 421c8b1 commit b19a05b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"dependencies": {
"@mitm/assetbundlecompiler": "^1.4.0",
"@toverux/expresse": "^2.1.0",
"@types/sanitize-filename": "^1.1.28",
"azure-storage": "^2.1.0",
"body-parser": "^1.17.1",
"boom": "^5.1.0",
Expand All @@ -62,6 +63,7 @@
"pify": "^3.0.0",
"pug": "^2.0.0-rc.1",
"raven": "^2.1.0",
"sanitize-filename": "^1.6.1",
"source-map-support": "^0.4.15",
"toureiro": "^0.2.13",
"uuid": "^3.0.1",
Expand Down
4 changes: 3 additions & 1 deletion src/converter/steps/02_exec_assetbundlecompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import * as pify from 'pify';
import * as sanitize from 'sanitize-filename';
import { bundle, setUnityPath } from '@mitm/assetbundlecompiler';
import config from '../../config';
import { IConversion } from '../../models/IConversion';
Expand Down Expand Up @@ -31,7 +32,8 @@ export async function process(
progress: ProgressFn
): Promise<void> {
const tmpDir = path.resolve(`${os.tmpdir()}/chuck-exec-assetbundlecompiler-${Date.now()}`);
const assetBundlePath = path.join(tmpDir, conv.assetBundleName);
const sanitizedBundleName = sanitize(conv.assetBundleName);
const assetBundlePath = path.join(tmpDir, sanitizedBundleName);

await pify(fs.mkdir)(tmpDir);

Expand Down
3 changes: 2 additions & 1 deletion src/converter/steps/03_upload_bundle.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as azure from 'azure-storage';
import * as pify from 'pify';
import * as sanitize from 'sanitize-filename';
import config from '../../config';
import { IConversion } from '../../models/IConversion';
import { IStepDescription, ProgressFn } from './step';
Expand All @@ -22,7 +23,7 @@ export async function process(conv: IConversion, context: ICompilerStepContext,

const blobService = getBlobService(conv);

const blobName = conv.assetBundleName;
const blobName = sanitize(conv.assetBundleName);
const container = conv.azure.container;

const createBlob = pify(blobService.createBlockBlobFromLocalFile.bind(blobService));
Expand Down
20 changes: 20 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@
dependencies:
"@types/node" "*"

"@types/sanitize-filename@^1.1.28":
version "1.1.28"
resolved "https://registry.yarnpkg.com/@types/sanitize-filename/-/sanitize-filename-1.1.28.tgz#baa18f5ce4330fcbb3ea7b62f65550963d9aaa07"

"@types/serve-static@*":
version "1.7.31"
resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.7.31.tgz#15456de8d98d6b4cff31be6c6af7492ae63f521a"
Expand Down Expand Up @@ -3221,6 +3225,12 @@ safe-buffer@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7"

sanitize-filename@^1.6.1:
version "1.6.1"
resolved "https://registry.yarnpkg.com/sanitize-filename/-/sanitize-filename-1.6.1.tgz#612da1c96473fa02dccda92dcd5b4ab164a6772a"
dependencies:
truncate-utf8-bytes "^1.0.0"

sax@0.5.2:
version "0.5.2"
resolved "https://registry.yarnpkg.com/sax/-/sax-0.5.2.tgz#735ffaa39a1cff8ffb9598f0223abdb03a9fb2ea"
Expand Down Expand Up @@ -3616,6 +3626,12 @@ trim-newlines@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613"

truncate-utf8-bytes@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/truncate-utf8-bytes/-/truncate-utf8-bytes-1.0.2.tgz#405923909592d56f78a5818434b0b78489ca5f2b"
dependencies:
utf8-byte-length "^1.0.1"

tslib@^1.6.0:
version "1.7.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.7.1.tgz#bc8004164691923a79fe8378bbeb3da2017538ec"
Expand Down Expand Up @@ -3726,6 +3742,10 @@ update-notifier@0.5.0:
semver-diff "^2.0.0"
string-length "^1.0.0"

utf8-byte-length@^1.0.1:
version "1.0.4"
resolved "https://registry.yarnpkg.com/utf8-byte-length/-/utf8-byte-length-1.0.4.tgz#f45f150c4c66eee968186505ab93fcbb8ad6bf61"

util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
Expand Down

0 comments on commit b19a05b

Please sign in to comment.