From e4cee770391bfd93d3e12c7fc1baa97c50a49c74 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 14 Jan 2008 17:04:29 -0500 Subject: [PATCH] Add sanity checks to BSPrinterNavigation when setting focus or sections * PrinterNavigation.php (BSPrinterNavigation::addFocus): Make sure the key is unique and exists before accepting it (BSPrinterNavigation::addSection): ditto --- PrinterNavigation.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/PrinterNavigation.php b/PrinterNavigation.php index ba70231..7a7e33c 100644 --- a/PrinterNavigation.php +++ b/PrinterNavigation.php @@ -75,6 +75,10 @@ class BSPrinterNavigation */ public function addFocus($key) { + if (sizeof($this->structure->xpath('//*[@key="' . $key . '"]')) != 1) + { + throw new Exception('The key passed to BSPrinterNavigation::addFocus() is either too vague or nonexistent'); + } $this->focusKeys[] = $key; } @@ -86,6 +90,10 @@ class BSPrinterNavigation */ public function addSection($key) { + if (sizeof($this->structure->xpath('//*[@key="' . $key . '"]')) != 1) + { + throw new Exception('The key passed to BSPrinterNavigation::addSection() is either too vague or nonexistent'); + } $this->displaySections[] = $key; } -- 2.22.5