Fix case sensitive check to be case insensitive

Case sensitivity between os.getcwd and os.realpath can fail due to different drive letter casing. C:\ vs c:\. This change addresses that by normalizing the strings before comparing.
This commit is contained in:
David Ford 2022-08-29 12:46:24 -05:00
parent 132d23e55d
commit 31fa92a83f
3 changed files with 10 additions and 5 deletions

4
.gitattributes vendored Normal file
View File

@ -0,0 +1,4 @@
# Auto normalizes line endings on commit so devs don't need to change local settings.
# Only effects text files and ignores other file types.
# For more info see: https://www.aleksandrhovhannisyan.com/blog/crlf-vs-lf-normalizing-line-endings-in-git/
* text=auto

View File

@ -17,8 +17,8 @@ class DreamServer(BaseHTTPRequestHandler):
self.wfile.write(content.read())
else:
path = "." + self.path
cwd = os.getcwd()
is_in_cwd = os.path.commonprefix((os.path.realpath(path), cwd)) == cwd
cwd = os.getcwd().lower()
is_in_cwd = os.path.commonprefix((os.path.realpath(path).lower(), cwd)) == cwd
if not (is_in_cwd and os.path.exists(path)):
self.send_response(404)
return

View File

@ -1,6 +1,7 @@
<html>
<html lang="en">
<head>
<title>Stable Diffusion Dream Server</title>
<meta charset="utf-8">
<link rel="icon" href="data:,">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@ -13,7 +14,7 @@
<form id="generate-form" method="post" action="#">
<fieldset id="fieldset-search">
<input type="text" id="prompt" name="prompt">
<input type="text" id="prompt" name="prompt" placeholder="Create something! e.g. A cottage on a hill">
<input type="submit" id="submit" value="Generate">
</fieldset>
<fieldset id="fieldset-config">
@ -70,7 +71,7 @@
<input value="0.8" min="0" max="1" type="number" id="gfpgan_strength" name="gfpgan_strength" step="0.05">
<label title="Upscaling to perform using ESRGAN." for="upscale_level">Upscaling Level</label>
<select id="upscale_level" name="upscale_level" value="">
<option value="" selected></option>
<option value="" selected>None</option>
<option value="2">2x</option>
<option value="4">4x</option>
</select>