From 053714bf108c97eeaec398e2ecead23747a3576d Mon Sep 17 00:00:00 2001 From: C-3PO Date: Fri, 22 Jun 2018 18:21:27 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=92=20Verify=20input=20to=20releasePat?= =?UTF-8?q?hs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ssn/releasePaths.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ssn/releasePaths.ts b/src/ssn/releasePaths.ts index 530a578..f24b6f3 100644 --- a/src/ssn/releasePaths.ts +++ b/src/ssn/releasePaths.ts @@ -1,5 +1,8 @@ +import { Product } from '../interfaces/ISettings'; +import verifyProductName from '../ssn/verifyProductName'; + /** For the given release in the given product, returns from which releases we can patch to this release. */ -function getFroms({ product, to: releaseTo}: {product: string, to: number}) { +function getFroms({ product, to: releaseTo}: {product: Product, to: number}) { //The launcher (patcher, patcher2014, patcher2017) is always installing from -1, never from a previous version if (product.startsWith('patcher')) { return [-1]; @@ -47,8 +50,16 @@ function getFroms({ product, to: releaseTo}: {product: string, to: number}) { * Does not actually look at the manifest.xml file but theorizes on possible patches based on the usually created patches, allowing * us to find release pathes for products that have not been released yet. */ -export default function findReleasePath({ product, from, to}: {product: string, from: number, to: number}): Array<[number, number]> { +export default function findReleasePath({ product, from, to}: {product: Product, from: number, to: number}): Array<[number, number]> { + //Verify function arguments + if (!verifyProductName(product)) { + throw new Error(`"${product}" is not a valid product.`); + } + //We assume that "from < to" is true for all patches + if (from > to) { + throw new Error('Cannot patch backwards; to must be greater than from.'); + } const froms = getFroms({ product, to });