forked from yt-dlp/yt-dlp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The shell escape function is now using `""` instead of `\"`. `utils.Popen` has been patched to properly quote commands. Prior to this fix using `--exec` together with `%q` when on Windows could cause remote code to execute. See GHSA-42h4-v29r-42qg for reference. Authored by: Grub4K
- Loading branch information
Showing
6 changed files
with
46 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
import io | ||
import itertools | ||
import json | ||
import subprocess | ||
import xml.etree.ElementTree | ||
|
||
from yt_dlp.compat import ( | ||
|
@@ -28,6 +29,7 @@ | |
InAdvancePagedList, | ||
LazyList, | ||
OnDemandPagedList, | ||
Popen, | ||
age_restricted, | ||
args_to_str, | ||
base_url, | ||
|
@@ -2388,6 +2390,20 @@ def test_extract_basic_auth(self): | |
assert extract_basic_auth('http://user:@foo.bar') == ('http://foo.bar', 'Basic dXNlcjo=') | ||
assert extract_basic_auth('http://user:[email protected]') == ('http://foo.bar', 'Basic dXNlcjpwYXNz') | ||
|
||
@unittest.skipUnless(compat_os_name == 'nt', 'Only relevant on Windows') | ||
def test_Popen_windows_escaping(self): | ||
def run_shell(args): | ||
stdout, stderr, error = Popen.run( | ||
args, text=True, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
assert not stderr | ||
assert not error | ||
return stdout | ||
|
||
# Test escaping | ||
assert run_shell(['echo', 'test"&']) == '"test""&"\n' | ||
# Test if delayed expansion is disabled | ||
assert run_shell(['echo', '^!']) == '"^!"\n' | ||
assert run_shell('echo "^!"') == '"^!"\n' | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters