Permalink
Browse files

fixed: accept empty strings for the Input.SendText JSON-RPC call, as …

…they are perfectly valid input
  • Loading branch information...
bobo1on1
bobo1on1 committed Oct 13, 2012
1 parent 7493741 commit b23adb3a74ffcecbc18f240d9cd22628a5c3b95a
Showing with 6 additions and 4 deletions.
  1. +5 −3 xbmc/interfaces/json-rpc/InputOperations.cpp
  2. +1 −1 xbmc/interfaces/json-rpc/ServiceDescription.h
@@ -94,16 +94,18 @@ JSONRPC_STATUS CInputOperations::activateWindow(int windowID)
JSONRPC_STATUS CInputOperations::SendText(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
- std::string text = parameterObject["text"].asString();
- if (text.empty())
+ const CVariant& textvar = parameterObject["text"];
+ if (!textvar.isString())
return InvalidParams;
+ std::string textstr = textvar.asString();
+
CGUIWindow *window = g_windowManager.GetWindow(g_windowManager.GetFocusedWindow());
if (!window)
return InternalError;
CGUIMessage msg(GUI_MSG_SET_TEXT, 0, 0);
- msg.SetLabel(text);
+ msg.SetLabel(textstr);
msg.SetParam1(parameterObject["done"].asBoolean() ? 1 : 0);
CApplicationMessenger::Get().SendGUIMessage(msg, window->GetID());
return ACK;
@@ -2747,7 +2747,7 @@ namespace JSONRPC
"\"transport\": \"Response\","
"\"permission\": \"Navigate\","
"\"params\": ["
- "{ \"name\": \"text\", \"type\": \"string\", \"minLength\": 1, \"required\": true, \"description\": \"Unicode text\" },"
+ "{ \"name\": \"text\", \"type\": \"string\", \"required\": true, \"description\": \"Unicode text\" },"
"{ \"name\": \"done\", \"type\": \"boolean\", \"default\": true, \"description\": \"Whether this is the whole input or not (closes an open input dialog if true).\" }"
"],"
"\"returns\": \"string\""

2 comments on commit b23adb3

@Montellese

This comment has been minimized.

Show comment
Hide comment
@Montellese

Montellese Oct 13, 2012

Member

You don't need the extra CVariant and the check whether it's a string or not. CJSONServiceDescription takes care of that and will throw an error at the JSON-RPC client if the "text" parameter is not a string. So basically you could have just dropped the

if (text.empty())
  return InvalidParams;

part. Plus you also need to make the same change you did to ServiceDescription.h in methods.json. I'll fix it up, just as an FYI.

Member

Montellese replied Oct 13, 2012

You don't need the extra CVariant and the check whether it's a string or not. CJSONServiceDescription takes care of that and will throw an error at the JSON-RPC client if the "text" parameter is not a string. So basically you could have just dropped the

if (text.empty())
  return InvalidParams;

part. Plus you also need to make the same change you did to ServiceDescription.h in methods.json. I'll fix it up, just as an FYI.

@bobo1on1

This comment has been minimized.

Show comment
Hide comment
@bobo1on1

bobo1on1 Oct 13, 2012

Member

Crap.

Member

bobo1on1 replied Oct 13, 2012

Crap.

Please sign in to comment.