Improve validation for Samsung and Sony
This commit is contained in:
1 parent
089d7cf1b0
commit
2bab662137
2 files changed
+5
-2
No files matched your search
@@ -165,7 +165,7 @@ export let Sony: BIOSDecoder = {
|
||||
model: BIOSModels.Sony,
|
||||
name: "Sony",
|
||||
examples: ["1234567"],
|
||||
check: (s) => /\d{7}/gi.test(s),
|
||||
check: (s) => /^\d{7}$/i.test(s),
|
||||
solve: (s) => {
|
||||
let res = SonySolver(s);
|
||||
return res ? [res] : [];
|
||||
@@ -176,7 +176,7 @@ export let Samsung: BIOSDecoder = {
|
||||
model: BIOSModels.Samsung,
|
||||
name: "Samsung",
|
||||
examples: ["07088120410C0000"],
|
||||
check: (s) => /[0-9ABCDEF]+/gi.test(s) && (
|
||||
check: (s) => /^[0-9ABCDEF]+$/i.test(s) && (
|
||||
s.length === 12 || s.length === 14 || s.length === 16
|
||||
),
|
||||
solve: SamsungSolver
|
||||
|
||||
@@ -10,6 +10,7 @@ describe("Decryp BIOS", function() {
|
||||
expect(bios.Sony.check("1234567")).toBe(true);
|
||||
expect(bios.Sony.check("0123456")).toBe(true);
|
||||
expect(bios.Sony.check("123o567")).toBe(false);
|
||||
expect(bios.Sony.check("1234567D")).toBe(false);
|
||||
});
|
||||
|
||||
it("Samsung key for 07088120410C0000 is 12345", function() {
|
||||
@@ -18,6 +19,8 @@ describe("Decryp BIOS", function() {
|
||||
|
||||
it("Samsung input validation", function() {
|
||||
expect(bios.Samsung.check("07088120410C0000")).toBe(true);
|
||||
expect(bios.Samsung.check("07088120410C000000")).toBe(false);
|
||||
expect(bios.Samsung.check("07088120410C000O")).toBe(false);
|
||||
expect(bios.Samsung.check("07088120410C")).toBe(true);
|
||||
expect(bios.Samsung.check("07088120410C00")).toBe(true);
|
||||
expect(bios.Samsung.check("0123456")).toBe(false);
|
||||
|
||||
Reference in new issue
Block a user