From 794004ac70e8fb7b09fcb8bd7eb226d03fdae9f5 Mon Sep 17 00:00:00 2001 From: gbtami Date: Fri, 20 Apr 2018 13:08:47 +0200 Subject: [PATCH] Fix handling multiple features in on line --- chess/xboard.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/chess/xboard.py b/chess/xboard.py index 92bed3699..4144ecd8f 100644 --- a/chess/xboard.py +++ b/chess/xboard.py @@ -19,6 +19,7 @@ # along with this program. If not, see . import concurrent.futures +import shlex import threading from chess.engine import EngineTerminatedException @@ -397,9 +398,8 @@ def _feature(self, features): Does not conform to the CECP spec regarding `done` and instead reads all the features atomically. """ - if features.startswith("option"): - features = features.replace("\"", "") - params = features.split("=")[1].split() + def _option(feature): + params = feature.split() name = params[0] type = params[1][1:] default = None @@ -431,12 +431,13 @@ def _feature(self, features): self.features.set_option(option.name, option) return - features = features.split() + features = shlex.split(features) feature_map = [feature.split("=") for feature in features] for (key, value) in feature_map: - value = value.strip("\"") if key == "variant": self.features.set_feature(key, value.split(",")) + elif key == "option": + _option(value) else: self.features.set_feature(key, value)