From 8eedf9e7c6041c8589193e449c8e695a7e89c93e Mon Sep 17 00:00:00 2001 From: Juanjo Diaz Date: Sat, 14 Jul 2018 01:39:55 +0200 Subject: [PATCH] Disallow nested ternaries --- .eslintrc | 2 +- core/des.js | 11 ++++++++++- core/util/events.js | 4 +++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.eslintrc b/.eslintrc index e0c2b582..3e540253 100644 --- a/.eslintrc +++ b/.eslintrc @@ -339,7 +339,7 @@ "no-negated-condition": "off", // disallow nested ternary expressions - // "no-nested-ternary": "error", + "no-nested-ternary": "error", // disallow use of the Object constructor "no-new-object": "error", diff --git a/core/des.js b/core/des.js index 8e24fcc3..abcc5892 100644 --- a/core/des.js +++ b/core/des.js @@ -144,7 +144,16 @@ export default function DES(passwd) { kn = []; for (let j = 0, l = 56; j < 56; ++j, l -= 8) { - l += l < -5 ? 65 : l < -3 ? 31 : l < -1 ? 63 : l === 27 ? 35 : 0; // PC1 + // PC1 + if (l < -5) { + l += 65; + } else if (l < -3) { + l += 31; + } else if (l < -1) { + l += 63; + } else if (l === 27) { + l += 35; + } const m = l & 0x7; pc1m[j] = ((keyBlock[l >>> 3] & (1 << m)) !== 0) ? 1 : 0; } diff --git a/core/util/events.js b/core/util/events.js index efb0a437..22c70236 100644 --- a/core/util/events.js +++ b/core/util/events.js @@ -11,7 +11,9 @@ */ export function getPointerEvent(e) { - return e.changedTouches ? e.changedTouches[0] : e.touches ? e.touches[0] : e; + if (e.changedTouches) return e.changedTouches[0]; + if (e.touches) return e.touches[0]; + return e; } export function stopEvent(e) {