forked from open-webui/open-webui
commit
f87805b46f
2 changed files with 4 additions and 18 deletions
|
@ -448,25 +448,11 @@ def store_doc(
|
||||||
|
|
||||||
log.info(f"file.content_type: {file.content_type}")
|
log.info(f"file.content_type: {file.content_type}")
|
||||||
try:
|
try:
|
||||||
is_valid_filename = True
|
|
||||||
unsanitized_filename = file.filename
|
unsanitized_filename = file.filename
|
||||||
if re.search(r'[\\/:"\*\?<>|\n\t ]', unsanitized_filename) is not None:
|
filename = os.path.basename(unsanitized_filename)
|
||||||
is_valid_filename = False
|
|
||||||
|
|
||||||
unvalidated_file_path = f"{UPLOAD_DIR}/{unsanitized_filename}"
|
file_path = f"{UPLOAD_DIR}/{filename}"
|
||||||
dereferenced_file_path = str(Path(unvalidated_file_path).resolve(strict=False))
|
|
||||||
if not dereferenced_file_path.startswith(UPLOAD_DIR):
|
|
||||||
is_valid_filename = False
|
|
||||||
|
|
||||||
if is_valid_filename:
|
|
||||||
file_path = dereferenced_file_path
|
|
||||||
else:
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=status.HTTP_400_BAD_REQUEST,
|
|
||||||
detail=ERROR_MESSAGES.DEFAULT(),
|
|
||||||
)
|
|
||||||
|
|
||||||
filename = file.filename
|
|
||||||
contents = file.file.read()
|
contents = file.file.read()
|
||||||
with open(file_path, "wb") as f:
|
with open(file_path, "wb") as f:
|
||||||
f.write(contents)
|
f.write(contents)
|
||||||
|
@ -477,7 +463,7 @@ def store_doc(
|
||||||
collection_name = calculate_sha256(f)[:63]
|
collection_name = calculate_sha256(f)[:63]
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
loader, known_type = get_loader(file.filename, file.content_type, file_path)
|
loader, known_type = get_loader(filename, file.content_type, file_path)
|
||||||
data = loader.load()
|
data = loader.load()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -7,7 +7,7 @@ ollama
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- define "ollama.url" -}}
|
{{- define "ollama.url" -}}
|
||||||
{{- printf "http://%s.%s.svc.cluster.local:%d/api" (include "ollama.name" .) (.Release.Namespace) (.Values.ollama.service.port | int) }}
|
{{- printf "http://%s.%s.svc.cluster.local:%d/" (include "ollama.name" .) (.Release.Namespace) (.Values.ollama.service.port | int) }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "chart.name" -}}
|
{{- define "chart.name" -}}
|
||||||
|
|
Loading…
Reference in a new issue