[PrusaLink] Using single or double quotes in printer and room name does not work after initial setup
 
Notifications
Clear all

[PrusaLink] Using single or double quotes in printer and room name does not work after initial setup  

  RSS
cleo
 cleo
(@cleo)
Member
[PrusaLink] Using single or double quotes in printer and room name does not work after initial setup

PrusaLink version: 0.6.0

PrusaLink gives an "Error Action cannot be performed" message when attempting to use single or double quotes in the room or printer name. See attached screenshots for examples.

However, the setup wizard accepts these characters during initial setup and manually editing

prusa_printer_settings.ini to add or re-add quotes to the name works fine.

 

Posted : 26/12/2021 4:13 am
DanielAttia
(@danielattia)
Member
RE: [PrusaLink] Using single or double quotes in printer and room name does not work after initial setup

Have you tried changing the name and location using the Prusa Connect website?

Posted : 27/12/2021 11:43 pm
cleo
 cleo
(@cleo)
Member
Topic starter answered:
RE: [PrusaLink] Using single or double quotes in printer and room name does not work after initial setup

Changing the name and location works on the Prusa Connect website when using quotes, but changes in Prusa Connect aren't reflected in PrusaLink or vice versa.

Posted : 30/12/2021 9:45 am
cleo
 cleo
(@cleo)
Member
Topic starter answered:
RE:

Some further investigation shows the issue is likely that the quote characters are intended to be disallowed, but the check is only performed in settings.py:

PRINTER_MISSING_CREDENTIALS = "Both name and location credentials are required"
PRINTER_INVALID_CREDENTIALS = "Name or location cointains invalid characters"
INVALID_CHARACTERS = ['\'', '\"',"$"]
...
def api_settings_set(req):
...
    # printer settings
    if printer:
        name = printer.get('name')
        location = printer.get('location')
        for character in INVALID_CHARACTERS:
            if character in name or character in location:
                errors_['printer'] = \
                    {'invalid_credentials': PRINTER_INVALID_CREDENTIALS}
        if not name or not location:
            errors_['printer'] = \
                {'missing_credentials': PRINTER_MISSING_CREDENTIALS}

and not wizard.py:

def wizard_auth_post(req):
    """Check and store values from wizard_auth page."""
    form = FieldStorage(req,
                        keep_blank_values=app.keep_blank_values,
                        strict_parsing=app.strict_parsing)
    app.wizard.username = form.get('username', '').strip()
    password = form.get('password', '')
    repassword = form.get('repassword', '')
    app.wizard.api_key = form.get('api_key', '').strip()
    if not app.wizard.check_auth(password, repassword):
        redirect('/wizard/auth')
    app.wizard.set_digest(password)
    redirect('/wizard/printer')

and the error returned from api_settings_set in settings.py when trying to update the name or location is not well handled in the web interface, only displaying a generic error message.

It is not a major problem for me but the user should be correctly informed about the issue and the check for excluded characters, if ultimately required, performed in all applicable locations (Link, Connect) and not just in the Link settings after setup.

Posted : 30/12/2021 3:00 pm
Tojik and DanielAttia liked
Share: