mirror of
https://github.com/iptv-org/iptv.git
synced 2026-11-27 19:16:32 +02:00
fix: keep %25 escapes when playlist:format normalizes links
decodeURI decodes %25, so normalizeURL turned an encoded percent sign into a bare "%": in the path (normalize-url runs decodeURI on the pathname) a%2520b became a%20b, a different file, and in the query token=50%25off became token=50%off, a malformed escape. %25 is now swapped for a placeholder before normalize-url and put back after decoding.
This commit is contained in:
+4
-1
@@ -59,10 +59,12 @@ function sortQueryParameters(url: string): string {
|
||||
}
|
||||
|
||||
export function normalizeURL(url: string): string {
|
||||
// decodeURI, here and inside normalize-url, would turn %25 into a bare "%", so it is swapped
|
||||
// for a placeholder that is put back once the link is decoded
|
||||
let normalized: string
|
||||
try {
|
||||
normalized = sortQueryParameters(
|
||||
normalizeUrl(url, { stripWWW: false, sortQueryParameters: false })
|
||||
normalizeUrl(url.replace(/%25/gi, '\uE000'), { stripWWW: false, sortQueryParameters: false })
|
||||
)
|
||||
} catch {
|
||||
return url.replace(/\s/g, '+')
|
||||
@@ -75,6 +77,7 @@ export function normalizeURL(url: string): string {
|
||||
} catch {
|
||||
decoded = normalized
|
||||
}
|
||||
decoded = decoded.replace(/\uE000|%EE%80%80/gi, '%25')
|
||||
|
||||
// "+" means a space only in the query; in the path it is a plus sign
|
||||
const queryStart = decoded.indexOf('?')
|
||||
|
||||
Reference in New Issue
Block a user