def create_dishwasher(name: str, brand: str, cost: int, cve: str) -> str:
try:
query = "INSERT INTO dishwashers VALUES ('{inserted_by}', '{id}', '{object}')"
id = get_new_id()
new_dishwasher = DishWasher(id, name, brand, cost, cve)
if "user" in request.cookies:
inserted_by = base64.b64decode(request.cookies["user"]).decode('utf-8')
else:
inserted_by = "no one :("
if len(inserted_by) > 255:
return ""
for c in inserted_by:
if c not in string.printable[:-2]:
return ""
if re.search(r"sleep", inserted_by, flags=re.IGNORECASE):
return ""
if re.search(r"benchmark", inserted_by, flags=re.IGNORECASE):
return ""
if re.search(r"wait", inserted_by, flags=re.IGNORECASE):
return ""
if insert(query.format(id=id, object=yaml.dump(new_dishwasher), inserted_by=inserted_by)):
return id
except Exception as e:
print(e, file=sys.stderr)
return ""
评论列表
文章目录