mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-19 07:42:09 +00:00
improved url encodng logic for ios
This commit is contained in:
parent
43d4db022c
commit
96da369f62
1 changed files with 25 additions and 6 deletions
|
|
@ -183,13 +183,32 @@ const KSPlayerCore: React.FC = () => {
|
|||
try {
|
||||
// Validate URL first
|
||||
const urlObj = new URL(url);
|
||||
|
||||
|
||||
// Only decode if the URL appears to be double-encoded
|
||||
// Check if URL contains encoded characters that shouldn't be there
|
||||
const hasDoubleEncoding = url.includes('%25') ||
|
||||
(url.includes('%2F') && url.includes('//')) ||
|
||||
(url.includes('%3A') && url.includes('://'));
|
||||
|
||||
// Be more conservative - only check for clear double-encoding indicators
|
||||
|
||||
// Check 1: %25 indicates double-encoded % character
|
||||
const hasDoubleEncodedPercent = url.includes('%25');
|
||||
|
||||
// Check 2: Only flag %2F + // if encoded slashes appear in the path/domain part
|
||||
// (not just in query params where they might be legitimate base64/etc)
|
||||
const hasProblematicEncodedSlashes = (() => {
|
||||
const beforeQuery = url.split('?')[0]; // Get URL before query params
|
||||
return beforeQuery.includes('%2F') && beforeQuery.includes('//');
|
||||
})();
|
||||
|
||||
// Check 3: Only flag %3A + :// if colons are encoded in the scheme
|
||||
const hasProblematicEncodedColons = (() => {
|
||||
const schemeEnd = url.indexOf('://');
|
||||
if (schemeEnd === -1) return false;
|
||||
const schemePart = url.substring(0, schemeEnd);
|
||||
return schemePart.includes('%3A');
|
||||
})();
|
||||
|
||||
const hasDoubleEncoding = hasDoubleEncodedPercent ||
|
||||
hasProblematicEncodedSlashes ||
|
||||
hasProblematicEncodedColons;
|
||||
|
||||
if (hasDoubleEncoding) {
|
||||
logger.log('[VideoPlayer] Detected double-encoded URL, decoding once');
|
||||
return decodeURIComponent(url);
|
||||
|
|
|
|||
Loading…
Reference in a new issue