Skip to content

Commit 45d1823

Browse files
committed
Throw exception if security token not found.
1 parent 278da39 commit 45d1823

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Gwt/Client.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ private function downloadCSV_XTRA($site, $tableName, DateTime $dateStart, DateTi
579579
/**
580580
* Regular Expression to find the Security Token for a download file.
581581
*
582+
* @throws Exception
582583
* @param string $uri A Webmaster Tools Desktop Service URI.
583584
* @param string $delimiter Trailing delimiter for the regex.
584585
* @param string $dlUri
@@ -590,9 +591,11 @@ private function getToken($uri, $delimiter, $dlUri='')
590591
$tmp = $this->getData($uri);
591592

592593
preg_match_all("#$dlUri.*?46security_token(.*?)$delimiter#si", $tmp, $matches);
593-
return isset($matches[1][0])
594-
? substr($matches[1][0], 3, -1)
595-
: ''
596-
;
594+
595+
if (!isset($matches[1][0])) {
596+
throw new Exception('Failed to extract token');
597+
}
598+
599+
return substr($matches[1][0], 3, -1);
597600
}
598601
}

0 commit comments

Comments
 (0)