From d07a1aacd7319106f9a064dad2d2797c055c001b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabrice=20Desr=C3=A9?= Date: Thu, 11 Apr 2013 07:45:02 -0700 Subject: [PATCH] Bug 853716 - Let the SMS protocol handler deal with sms: url without numbers r=baku --- b2g/components/SmsProtocolHandler.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/b2g/components/SmsProtocolHandler.js b/b2g/components/SmsProtocolHandler.js index dc12ab45022c..cfefcff03953 100644 --- a/b2g/components/SmsProtocolHandler.js +++ b/b2g/components/SmsProtocolHandler.js @@ -42,11 +42,24 @@ SmsProtocolHandler.prototype = { newChannel: function Proto_newChannel(aURI) { let number = TelURIParser.parseURI('sms', aURI.spec); + let body = ""; + let query = aURI.spec.split("?")[1]; - if (number) { + if (query) { + let params = query.split("&"); + params.forEach(function(aParam) { + let [name, value] = aParam.split("="); + if (name === "body") { + body = decodeURIComponent(value); + } + }) + } + + if (number || body) { cpmm.sendAsyncMessage("sms-handler", { - number: number, - type: "websms/sms" }); + number: number || "", + type: "websms/sms", + body: body }); } throw Components.results.NS_ERROR_ILLEGAL_VALUE;