Skip to content

Commit

Permalink
✔ Fix MKV Attachment Illegal Filename ~
Browse files Browse the repository at this point in the history
  • Loading branch information
bifeldy committed Oct 15, 2023
1 parent 1f6c8a0 commit bc298fa
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dist/fansubid/browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<noscript>🎉 Harap Menyalakan JavaScript Untuk Dapat Mengakses Website Ini ✨</noscript>
</div>
<app-root></app-root>
<script src="runtime.1fe4f3a6432d05b2.js" type="module"></script><script src="polyfills.bbae203fdd01cf64.js" type="module"></script><script src="scripts.25bb5de51afc8a05.js" defer></script><script src="main.d8d51e3dfa9a9e96.js" type="module"></script>
<script src="runtime.1fe4f3a6432d05b2.js" type="module"></script><script src="polyfills.bbae203fdd01cf64.js" type="module"></script><script src="scripts.25bb5de51afc8a05.js" defer></script><script src="main.3de35e27ffd93d42.js" type="module"></script>


</body></html>
1 change: 1 addition & 0 deletions dist/fansubid/browser/main.3de35e27ffd93d42.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/fansubid/browser/main.d8d51e3dfa9a9e96.js

This file was deleted.

8 changes: 4 additions & 4 deletions dist/fansubid/browser/ngsw.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"configVersion": 1,
"timestamp": 1697348187326,
"timestamp": 1697376651187,
"index": "/index.html",
"assetGroups": [
{
Expand Down Expand Up @@ -40,7 +40,7 @@
"/common.b0527391eae3d4e8.js",
"/favicon.ico",
"/index.html",
"/main.d8d51e3dfa9a9e96.js",
"/main.3de35e27ffd93d42.js",
"/manifest.webmanifest",
"/polyfills.bbae203fdd01cf64.js",
"/runtime.1fe4f3a6432d05b2.js",
Expand Down Expand Up @@ -112,8 +112,8 @@
"/960.1e1fe3434266e9a4.js": "c649bd883373fc66f7e2781d27054b5da57413a3",
"/common.b0527391eae3d4e8.js": "d79410310958a1938a5c670f1661497780d97764",
"/favicon.ico": "071facb8fab2e4b3493dcfbb0b02d7bd21bca97e",
"/index.html": "cd661eb5ffb2f12f7b16d7bb8a4b9bc3c87c1f91",
"/main.d8d51e3dfa9a9e96.js": "bc30625aed39b3d9d08e0ac2ec8aad8363955c55",
"/index.html": "e73a358a85695dfc726310304be134445f81e0d1",
"/main.3de35e27ffd93d42.js": "48200d3536fea2feb02d4da6d5bd1d0f8a8deed2",
"/manifest.webmanifest": "eafb5426cdc9fd714787e5453af315b9972875a3",
"/polyfills.bbae203fdd01cf64.js": "a59f17cf29cb649f708d7ec7aa6b7247712859e1",
"/runtime.1fe4f3a6432d05b2.js": "981b9021c6e1050c8f7765be53b5b74682a18960",
Expand Down
2 changes: 1 addition & 1 deletion dist/fansubid/server/main.js

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions src/api/services/mkv-extract.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { createReadStream } from 'node:fs';

import { Injectable } from '@nestjs/common';

import { CONSTANTS } from '../../constants';

import { GlobalService } from './global.service';

@Injectable()
Expand Down Expand Up @@ -93,10 +95,9 @@ export class MkvExtractService {
this.gs.log(`[MKVEXTRACT_DATA_CHUNK] ⌛ ${fileName} -- ${chunk[0]} -- ${chunk[1].name} -- ${chunk[1].dataSize} 🧬`);
switch (chunk[0]) {
case 'end':
// if (chunk[1].name === 'Info') {
// fileStream.destroy();
// }
if (chunk[1].name === 'TrackEntry') {
if (chunk[1].name === 'unknown') {
fileStream.destroy(new Error(`Unknown 'End'`));
} else if (chunk[1].name === 'TrackEntry') {
if (trackTypeTemp === 0x11) {
tracks.push(trackIndexTemp);
trackData.push([trackDataTemp]);
Expand All @@ -106,12 +107,12 @@ export class MkvExtractService {
break;
case 'tag':
if (chunk[1].name === 'unknown') {
fileStream.destroy(new Error('Unknown File Tag'));
fileStream.destroy(new Error(`Unknown 'Tag'`));
} else if (chunk[1].name === 'FileName') {
if (!files[currentFile]) {
files[currentFile] = {};
}
files[currentFile].name = chunk[1].data.toString();
files[currentFile].name = chunk[1].data.toString().replace(CONSTANTS.regexIllegalFileName, '-');
} else if (chunk[1].name === 'FileData') {
if (!files[currentFile]) {
files[currentFile] = {};
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const CONSTANTS = {
regexEmail: /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/,
regexEmailMulti: /^[^a-z0-9_]*([a-z0-9_+\-.%]+@[a-z0-9_\-.]+\.[a-z]+[^a-z0-9_]*,{1}[^a-z0-9_]*)*([a-z0-9_+\-.%]+@[a-z0-9_\-.]+\.[a-z]+)[^a-z0-9_]*$/,
regexEnglishKeyboardKeys: /^[a-zA-Z0-9~`!@#\$%\^&\*\(\)_\-\+={\[\}\]\|\\:;"'<,>\.\?\/ \n]*$/,
regexIllegalFileName: /[/\\?%*:|"<>]/g,
regexJapaneseKeyboardKeys: /[一-龠ぁ-ゔァ-ヴーa-zA-Z0-9々〆〤、。]+/u,
regexUrl: /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/,
retryDdlUploadMaxCount: 5,
Expand Down

0 comments on commit bc298fa

Please sign in to comment.