Skip to content

Commit

Permalink
gcode: Validate extended g-code command names
Browse files Browse the repository at this point in the history
Extended g-code command names may only contain A-Z, 0-9, and
underscore.

Signed-off-by: Kevin O'Connor <[email protected]>
  • Loading branch information
KevinOConnor committed Nov 26, 2024
1 parent 5b494eb commit a943462
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions klippy/gcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ def register_command(self, cmd, func, when_not_ready=False, desc=None):
raise self.printer.config_error(
"gcode command %s already registered" % (cmd,))
if not self.is_traditional_gcode(cmd):
if cmd.upper() != cmd or not cmd.replace('_', '').isalnum():
raise self.printer.config_error(
"Can't register '%s' as it is an invalid name" % (cmd,))
origfunc = func
func = lambda params: origfunc(self._get_extended_params(params))
self.ready_gcode_handlers[cmd] = func
Expand Down

0 comments on commit a943462

Please sign in to comment.