Bläddra i källkod

Magic operation now recognises useful operations such as 'Render Image' even though their output cannot be analysed

n1474335 7 år sedan
förälder
incheckning
27ec4aa923
3 ändrade filer med 34 tillägg och 14 borttagningar
  1. 10 5
      src/core/FlowControl.js
  2. 2 1
      src/core/config/OperationConfig.js
  3. 22 8
      src/core/lib/Magic.js

+ 10 - 5
src/core/FlowControl.js

@@ -294,13 +294,14 @@ const FlowControl = {
             let language = "",
                 fileType = "",
                 matchingOps = "",
+                useful = "",
                 validUTF8 = option.isUTF8 ? "Valid UTF8\n" : "";
 
-            if (option.languageScores[0].probability > 0.00001) {
-                let likelyLangs = option.languageScores.filter(l => l.probability > 0.2);
+            if (option.languageScores[0].probability > 0) {
+                let likelyLangs = option.languageScores.filter(l => l.probability > 0);
                 if (likelyLangs.length < 1) likelyLangs = [option.languageScores[0]];
-                language = "Language:\n    " + likelyLangs.map(lang => {
-                    return `${Magic.codeToLanguage(lang.lang)} ${(lang.probability * 100).toFixed(2)}%`;
+                language = "Possible languages:\n    " + likelyLangs.map(lang => {
+                    return Magic.codeToLanguage(lang.lang);
                 }).join("\n    ") + "\n";
             }
 
@@ -312,10 +313,14 @@ const FlowControl = {
                 matchingOps = `Matching ops: ${[...new Set(option.matchingOps.map(op => op.op))].join(", ")}\n`;
             }
 
+            if (option.useful) {
+                useful = "Useful op detected\n";
+            }
+
             output += `<tr>
                 <td><a href="#${recipeURL}">${Utils.generatePrettyRecipe(option.recipe, true)}</a></td>
                 <td>${Utils.escapeHtml(Utils.printable(Utils.truncate(option.data, 99)))}</td>
-                <td>${language}${fileType}${matchingOps}${validUTF8}</td>
+                <td>${language}${fileType}${matchingOps}${useful}${validUTF8}</td>
             </tr>`;
         });
 

+ 2 - 1
src/core/config/OperationConfig.js

@@ -4091,7 +4091,8 @@ const OperationConfig = {
             {
                 match: "^(?:\\xff\\xd8\\xff|\\x89\\x50\\x4e\\x47|\\x47\\x49\\x46|.{8}\\x57\\x45\\x42\\x50|\\x42\\x4d)",
                 flags: "",
-                args: ["Raw"]
+                args: ["Raw"],
+                useful: true
             },
         ]
     },

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 22 - 8
src/core/lib/Magic.js


Vissa filer visades inte eftersom för många filer har ändrats