mirror of https://git.48k.eu/ogcp
views: remove accents in image name
Remove accents in image name string. Special characters are not supported for image names.master
parent
37efed8d30
commit
aab70b0222
|
@ -30,6 +30,7 @@ from ogcp.og_server import OGServer, servers
|
|||
from flask_babel import lazy_gettext as _l
|
||||
from flask_babel import gettext, _
|
||||
from ogcp import app, ogcp_cfg_path
|
||||
import unicodedata
|
||||
import ipaddress
|
||||
import requests
|
||||
import datetime
|
||||
|
@ -123,6 +124,10 @@ def is_valid_ip(ip):
|
|||
return False
|
||||
return True
|
||||
|
||||
def remove_accents(text):
|
||||
normalized_text = unicodedata.normalize('NFD', text)
|
||||
return ''.join(c for c in normalized_text if unicodedata.category(c) != 'Mn')
|
||||
|
||||
def ogserver_down(view):
|
||||
flash(_('Cannot talk to ogserver. Is ogserver down?'), category='error')
|
||||
return redirect(url_for(view))
|
||||
|
@ -2380,7 +2385,7 @@ def action_image_create():
|
|||
if r.status_code != requests.codes.ok:
|
||||
return ogserver_error('commands')
|
||||
|
||||
image_name = form.name.data.strip()
|
||||
image_name = remove_accents(form.name.data.strip())
|
||||
if ' ' in image_name:
|
||||
flash(_('No spaces allowed in image names'), category='error')
|
||||
return redirect(url_for('commands'))
|
||||
|
|
Loading…
Reference in New Issue