From f4ab86d368c4a658992f230eb4fb1852aa2bf355 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 2 Jul 2026 08:37:27 -0400 Subject: [PATCH] sts response validation --- CHANGELOG.md | 4 ++++ .../Services/Innertube/PlayerEndpoint.bs | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41dc1f01..d4fb5688 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +- Nothing worth mentioning yet. + ## [0.48.0] - 2026-07-01 ### Added diff --git a/playlet-lib/src/components/Services/Innertube/PlayerEndpoint.bs b/playlet-lib/src/components/Services/Innertube/PlayerEndpoint.bs index cae52279..61ff79e0 100644 --- a/playlet-lib/src/components/Services/Innertube/PlayerEndpoint.bs +++ b/playlet-lib/src/components/Services/Innertube/PlayerEndpoint.bs @@ -505,7 +505,9 @@ namespace Innertube cache = ReadAsciiFile("tmp:/sts_cache.json") if not StringUtils.IsNullOrEmpty(cache) json = StringUtils.ParseJsonSafe(cache) - return { sts: json["sts"] } + if IsAssociativeArray(json) and json["sts"] <> invalid + return { sts: json["sts"] } + end if end if request = HttpClient.Get(`${PLAYLET_SUPPORT_SERVER}/v1/sts`) @@ -523,8 +525,16 @@ namespace Innertube end if text = response.Text() + json = StringUtils.ParseJsonSafe(text) + if not IsAssociativeArray(json) or json["sts"] = invalid + error = "Invalid response from sts service" + LogError(error, text) + return { + error: error + } + end if + WriteAsciiFile("tmp:/sts_cache.json", text) - json = response.Json() return { sts: json["sts"] } end function