Skip to content

Commit 0ce7c33

Browse files
committed
Detect invalid content (#458)
1 parent 0adefba commit 0ce7c33

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

source/view.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6365,17 +6365,14 @@ view.ModelFactoryService = class {
63656365
{ name: 'Git LFS header', value: /^version https:\/\/git-lfs.github.com/ },
63666366
{ name: 'Git LFS header', value: /^\s*oid sha256:/ },
63676367
{ name: 'GGML data', value: /^lmgg|fmgg|tjgg|algg|fugg/ },
6368-
{ name: 'HTML markup', value: /^\s*<html(\s+[^>]+)?>/ },
6369-
{ name: 'HTML markup', value: /^\s*<!doctype\s*html>/ },
6370-
{ name: 'HTML markup', value: /^\s*<!DOCTYPE\s*html>/ },
6371-
{ name: 'HTML markup', value: /^\s*<!DOCTYPE\s*HTML>/ },
6368+
{ name: 'HTML markup', value: /^\s*<(html|HTML)(\s+[^>]+)?>/ },
6369+
{ name: 'HTML markup', value: /^\s*<!(doctype|DOCTYPE)\s*(html|HTML)>/ },
63726370
{ name: 'HTML markup', value: /^\s*<!DOCTYPE\s*HTML\s+(PUBLIC|SYSTEM)?/ },
63736371
{ name: 'Unity metadata', value: /^fileFormatVersion:/ },
63746372
{ name: 'Python source code', value: /^((#.*(\n|\r\n))|('''.*'''(\n|\r\n))|("""[\s\S]*""")|(\n|\r\n))*(import[ ]+[a-zA-Z_]\w*(\.[a-zA-Z_]\w*)*([ ]+as[ ]+[a-zA-Z]\w*)?[ ]*(,|;|\n|\r\n))/ },
63756373
{ name: 'Python source code', value: /^((#.*(\n|\r\n))|('''.*'''(\n|\r\n))|("""[\s\S]*""")|(\n|\r\n))*(from[ ]+([a-zA-Z_]\w*(\.[a-zA-Z_]\w*)*)[ ]+import[ ]+[a-zA-Z]\w*)/ },
63766374
{ name: 'Python virtual environment configuration', value: /^home[ ]*=[ ]*/, identifier: /^pyvenv\.cfg/ },
6377-
{ name: 'Bash script', value: /^#!\/usr\/bin\/env\s/ },
6378-
{ name: 'Bash script', value: /^#!\/bin\/bash\s/ },
6375+
{ name: 'Bash script', value: /^(#!\/usr\/bin\/env|#!\/bin\/bash)\s/ },
63796376
{ name: 'TSD header', value: /^%TSD-Header-###%/ },
63806377
{ name: 'AppleDouble data', value: /^\x00\x05\x16\x07/ },
63816378
{ name: 'TensorFlow Hub module', value: /^\x08\x03$/, identifier: /^tfhub_module\.pb/ },
@@ -6395,12 +6392,11 @@ view.ModelFactoryService = class {
63956392
{ name: 'Cambricon model', value: /^\x7fMEF/ },
63966393
{ name: 'Cambricon model', value: /^cambricon_offline/ },
63976394
{ name: 'VNN model', value: /^\x2F\x4E\x00\x00.\x00\x00\x00/, identifier: /.vnnmodel$/ },
6398-
{ name: 'XGBoost model', value: /^binf/ }, // https://github.com/dmlc/xgboost/blob/master/src/learner.cc
6399-
{ name: 'XGBoost model', value: /^bs64/ }, // https://github.com/dmlc/xgboost/blob/master/src/learner.cc
6395+
{ name: 'XGBoost model', value: /^(binf|bs64)/ }, // https://github.com/dmlc/xgboost/blob/master/src/learner.cc
64006396
{ name: 'SQLite data', value: /^SQLite format/ },
64016397
{ name: 'Optimium model', value: /^EZMODEL/ }, // https://github.com/EZ-Optimium/Optimium,
6402-
{ name: 'undocumented NNC data', value: /^\xC0\x0F\x00\x00ENNC/ },
6403-
{ name: 'undocumented NNC data', value: /^\xBC\x0F\x00\x00ENNC/ }
6398+
{ name: 'undocumented NNC data', value: /^(\xC0|\xBC)\x0F\x00\x00ENNC/ },
6399+
{ name: 'Rich Text Format data', value: /^{\\rtf/ },
64046400
];
64056401
/* eslint-enable no-control-regex */
64066402
const buffer = stream.peek(Math.min(4096, stream.length));

0 commit comments

Comments
 (0)