Skip to content
This repository was archived by the owner on Apr 27, 2025. It is now read-only.

Commit 38b1aff

Browse files
Add JSON validation.
1 parent a84f1a1 commit 38b1aff

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

plugin.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: PocketVote
22
main: ProjectInfinity\PocketVote\PocketVote
3-
version: 2.1.0
4-
api: [3.0.0-ALPHA6, 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9]
3+
version: 2.1.1
4+
api: [3.0.0-ALPHA6, 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9, 3.0.0-ALPHA10]
55
author: ProjectInfinity
66
permissions:
77
pocketvote.admin:

src/ProjectInfinity/PocketVote/task/VRCCheckTask.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ public function onRun() {
4444

4545
$result = json_decode($res);
4646

47+
if(empty($result) || \is_string($result)) {
48+
$results[] = $this->createResult(true, 'Failed to parse JSON response from '.$url['host'].'. This is likely a problem with the mentioned site.');
49+
$this->setResult($results);
50+
curl_close($curl);
51+
return;
52+
}
53+
4754
if(!isset($result->voted) || !isset($result->claimed)) {
4855
$results[] = $this->createResult(true, 'Vote or claim field was missing in response from '.$url['host']);
4956
$this->setResult($results);
@@ -138,7 +145,7 @@ public function onCompletion(Server $server) {
138145

139146
foreach($results as $result) {
140147
if((object) $result->hasError()) {
141-
$server->getLogger()->error('[PocketVote] VRCCheckTask an issue occurred:'.$result->getError()['message']);
148+
$server->getLogger()->error('[PocketVote] VRCCheckTask: An issue occurred, you can ignore this unless it happens often: '.$result->getError()['message']);
142149
return;
143150
}
144151
$vote = (object) $result->getVotes();

0 commit comments

Comments
 (0)