fix: Implement manual JSON parsing for LSL 2048-char limit
LSL truncates HTTP responses at 2048 characters, breaking JSON parser. Implemented manual string parsing to extract: - tag_name (version) - html_url (release page) - published_at (release date) This works around LSL's HTTP response limitation and provides reliable GitHub release detection.
This commit is contained in:
parent
baca2893a5
commit
e96fb38f3e
1 changed files with 43 additions and 30 deletions
|
|
@ -287,42 +287,55 @@ default {
|
||||||
updateCheckInProgress = FALSE;
|
updateCheckInProgress = FALSE;
|
||||||
|
|
||||||
if (status == 200) {
|
if (status == 200) {
|
||||||
// Debug: Show response info first
|
if (VERBOSE_LOGGING) {
|
||||||
llOwnerSay("📊 Response received: " + (string)llStringLength(body) + " characters");
|
llOwnerSay("📊 GitHub response: " + (string)llStringLength(body) + " chars (LSL limit: 2048)");
|
||||||
|
|
||||||
// Try to find tag_name manually first as a test
|
|
||||||
integer tagPos = llSubStringIndex(body, "\"tag_name\":");
|
|
||||||
if (tagPos == -1) {
|
|
||||||
llOwnerSay("❌ GitHub response doesn't contain tag_name field");
|
|
||||||
llOwnerSay("🔍 First 200 chars: " + llGetSubString(body, 0, 199));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try simple JSON parsing
|
// LSL truncates HTTP responses at 2048 chars, breaking JSON parser
|
||||||
string latestVersion = llJsonGetValue(body, ["tag_name"]);
|
// Use manual parsing instead
|
||||||
|
string latestVersion = "";
|
||||||
|
string htmlUrl = "";
|
||||||
|
string publishedAt = "";
|
||||||
|
|
||||||
if (latestVersion == JSON_INVALID) {
|
// Extract tag_name manually
|
||||||
llOwnerSay("❌ LSL JSON parser failed on GitHub response");
|
integer tagStart = llSubStringIndex(body, "\"tag_name\":\"");
|
||||||
llOwnerSay("🔍 Manual search found tag_name at position: " + (string)tagPos);
|
if (tagStart != -1) {
|
||||||
// Try to extract version manually
|
integer versionStart = tagStart + 12; // Skip '"tag_name":"'
|
||||||
string searchStr = llGetSubString(body, tagPos + 12, tagPos + 50);
|
integer versionEnd = llSubStringIndex(llGetSubString(body, versionStart, -1), "\"");
|
||||||
llOwnerSay("🔍 Around tag_name: " + searchStr);
|
if (versionEnd != -1) {
|
||||||
return;
|
latestVersion = llGetSubString(body, versionStart, versionStart + versionEnd - 1);
|
||||||
}
|
|
||||||
|
|
||||||
// If we get here, JSON parsing worked
|
|
||||||
string htmlUrl = llJsonGetValue(body, ["html_url"]);
|
|
||||||
string publishedAt = llJsonGetValue(body, ["published_at"]);
|
|
||||||
|
|
||||||
// Parse release notes with error handling
|
|
||||||
string releaseNotes = llJsonGetValue(body, ["body"]);
|
|
||||||
if (releaseNotes == JSON_INVALID) {
|
|
||||||
releaseNotes = "Release notes unavailable";
|
|
||||||
if (VERBOSE_LOGGING) {
|
|
||||||
llOwnerSay("⚠️ Could not parse release notes - may contain special characters");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extract html_url manually
|
||||||
|
integer urlStart = llSubStringIndex(body, "\"html_url\":\"");
|
||||||
|
if (urlStart != -1) {
|
||||||
|
integer urlValueStart = urlStart + 12; // Skip '"html_url":"'
|
||||||
|
integer urlEnd = llSubStringIndex(llGetSubString(body, urlValueStart, -1), "\"");
|
||||||
|
if (urlEnd != -1) {
|
||||||
|
htmlUrl = llGetSubString(body, urlValueStart, urlValueStart + urlEnd - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract published_at manually
|
||||||
|
integer pubStart = llSubStringIndex(body, "\"published_at\":\"");
|
||||||
|
if (pubStart != -1) {
|
||||||
|
integer pubValueStart = pubStart + 15; // Skip '"published_at":"'
|
||||||
|
integer pubEnd = llSubStringIndex(llGetSubString(body, pubValueStart, -1), "\"");
|
||||||
|
if (pubEnd != -1) {
|
||||||
|
publishedAt = llGetSubString(body, pubValueStart, pubValueStart + pubEnd - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (latestVersion == "") {
|
||||||
|
llOwnerSay("❌ Could not extract version from truncated GitHub response");
|
||||||
|
llOwnerSay("🔍 Response was cut off at 2048 characters");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip release notes parsing - response is truncated at 2048 chars
|
||||||
|
string releaseNotes = "Release notes available on GitHub (response truncated)";
|
||||||
|
|
||||||
llOwnerSay("=== 🔍 UPDATE CHECK RESULTS ===");
|
llOwnerSay("=== 🔍 UPDATE CHECK RESULTS ===");
|
||||||
llOwnerSay("📊 Current Version: v" + CURRENT_VERSION);
|
llOwnerSay("📊 Current Version: v" + CURRENT_VERSION);
|
||||||
llOwnerSay("✨ Latest GitHub Release: " + latestVersion);
|
llOwnerSay("✨ Latest GitHub Release: " + latestVersion);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue