Don't include /range/ in hash

See https://github.com/TeamPiped/Piped/issues/3211
This commit is contained in:
Kavin 2023-12-14 05:03:55 +00:00
parent 19dca8bdd0
commit e90eebcbd7
No known key found for this signature in database
GPG key ID: 6E4598CA5C92C41F

View file

@ -4,6 +4,7 @@ use once_cell::sync::Lazy;
use qstring::QString;
use regex::Regex;
use reqwest::{Body, Client, Request, Url};
use std::borrow::Cow;
use std::collections::BTreeMap;
use std::error::Error;
use std::io::ErrorKind;
@ -184,7 +185,20 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> {
hasher.update(&value);
}
let range_marker = b"/range/";
// Find the slice before "/range/"
if let Some(position) = path
.windows(range_marker.len())
.position(|window| window == range_marker)
{
// Update the hasher with the part of the path before "/range/"
// We add +1 to include the "/" in the hash
// This is done for DASH streams for the manifests provided by YouTube
hasher.update(&path[..(position + 1)]);
} else {
hasher.update(&path);
}
hasher.update(secret.as_bytes());