File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -258,13 +258,15 @@ def _is_safe_url(target: Optional[str]) -> bool:
258258 if not target :
259259 return False
260260
261- # Build an absolute URL based on the current host, then compare
262- ref_url = urlparse (request .host_url )
263- test_url = urlparse (urljoin (request .host_url , target ))
264- return (
265- test_url .scheme in ("http" , "https" )
266- and ref_url .netloc == test_url .netloc
267- )
261+ parsed = urlparse (target )
262+ if parsed .scheme or parsed .netloc or target .startswith ('//' ):
263+ return False
264+ if not parsed .path .startswith ('/' ):
265+ return False
266+ joined = urljoin (request .host_url , target )
267+ host = urlparse (request .host_url )
268+ j = urlparse (joined )
269+ return j .scheme in ("http" , "https" ) and j .netloc == host .netloc
268270
269271@app .route ('/set-language/<lang_code>' )
270272def set_language (lang_code ):
You can’t perform that action at this time.
0 commit comments