Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions shell.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,10 +548,21 @@ function getQueryString() {
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
try {
var responseJson = JSON.parse(xhr.responseText);
callback(responseJson);
var responseText = xhr.responseText;
// getting JSON part (first { to last })
var jsonStart = responseText.indexOf('{');
var jsonEnd = responseText.lastIndexOf('}');

if (jsonStart !== -1 && jsonEnd !== -1 && jsonEnd > jsonStart) {
var jsonText = responseText.substring(jsonStart, jsonEnd + 1);
var responseJson = JSON.parse(jsonText);
callback(responseJson);
} else {
throw new Error("No valid JSON found in response");
}
} catch (error) {
alert("Error while parsing response: " + error);
console.error("Response text:", xhr.responseText);
alert("Invalid JSON response. Check console for details.\nError: " + error);
}
}
};
Expand Down Expand Up @@ -601,5 +612,4 @@ function getQueryString() {
</div>
</div>
</body>

</html>
</html>