web_config: set new prompts via JSON instead of URI-encoded

Fixes problems with encoding and decoding Unicode from URL-encoded strings,
which was impossible to get right in Python 2.
This commit is contained in:
David Adam 2015-01-30 22:54:11 +08:00
parent d17ba69f9e
commit 78dfc57b1e
2 changed files with 3 additions and 3 deletions

View file

@ -140,7 +140,7 @@ controllers.controller("promptController", function($scope, $http) {
}
$scope.setNewPrompt = function(selectedPrompt) {
$http.post("set_prompt/","what=" + encodeURIComponent(selectedPrompt.function), { headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).success(function(data, status, headers, config){
$http.post("set_prompt/", {'fish_prompt': selectedPrompt.function,}).success(function(data, status, headers, config){
// Update attributes of current prompt and select it
$scope.samplePrompts[0].demo = selectedPrompt.demo;

View file

@ -816,8 +816,8 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
else:
output = ["Unable to delete history item"]
elif p == '/set_prompt/':
what = postvars.get('what')
if self.do_set_prompt_function(what[0]):
what = postvars.get('fish_prompt')
if self.do_set_prompt_function(what):
output = ["OK"]
else:
output = ["Unable to set prompt"]