diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-03 20:21:21 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-03 20:21:21 +0000 |
commit | 09100e3e3a7fb5feab84039cecfa35966fb312ce (patch) | |
tree | 01be0af6c8fc4f01591b860be3c7c67945edcb0b /remoting | |
parent | 037181f0c341a3e238fc8710116d49df734c541f (diff) | |
download | chromium_src-09100e3e3a7fb5feab84039cecfa35966fb312ce.zip chromium_src-09100e3e3a7fb5feab84039cecfa35966fb312ce.tar.gz chromium_src-09100e3e3a7fb5feab84039cecfa35966fb312ce.tar.bz2 |
Fix client to always handle error messages properly.
Changed JingleMessage::IsJingleMessage() to return false for error
messages, so that PepperSessionManager doesn't try to handle them.
Review URL: http://codereview.chromium.org/8956063
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116184 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/protocol/jingle_messages.cc | 12 | ||||
-rw-r--r-- | remoting/protocol/jingle_messages_unittest.cc | 29 |
2 files changed, 39 insertions, 2 deletions
diff --git a/remoting/protocol/jingle_messages.cc b/remoting/protocol/jingle_messages.cc index 6d0abd7..1e70a2b 100644 --- a/remoting/protocol/jingle_messages.cc +++ b/remoting/protocol/jingle_messages.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -135,7 +135,10 @@ XmlElement* FormatCandidate(const cricket::Candidate& candidate) { // static bool JingleMessage::IsJingleMessage(const buzz::XmlElement* stanza) { - return stanza->FirstNamed(QName(kJingleNamespace, "jingle")) != NULL; + return + stanza->Name() == QName(kJabberNamespace, "iq") && + stanza->Attr(QName("", "type")) == "set" && + stanza->FirstNamed(QName(kJingleNamespace, "jingle")) != NULL; } JingleMessage::JingleMessage() @@ -158,6 +161,11 @@ JingleMessage::~JingleMessage() { bool JingleMessage::ParseXml(const buzz::XmlElement* stanza, std::string* error) { + if (!IsJingleMessage(stanza)) { + *error = "Not a jingle message"; + return false; + } + const XmlElement* jingle_tag = stanza->FirstNamed(QName(kJingleNamespace, "jingle")); if (jingle_tag == NULL) { diff --git a/remoting/protocol/jingle_messages_unittest.cc b/remoting/protocol/jingle_messages_unittest.cc index b2fb179..228886b 100644 --- a/remoting/protocol/jingle_messages_unittest.cc +++ b/remoting/protocol/jingle_messages_unittest.cc @@ -314,5 +314,34 @@ TEST(JingleMessageReplyTest, ToXml) { } } +TEST(JingleMessageTest, ErrorMessage) { + const char* kTestSessionInitiateErrorMessage = + "<iq to='user@gmail.com/chromoting016DBB07' type='error' " + "from='user@gmail.com/chromiumsy5C6A652D' " + "xmlns='jabber:client'><jingle xmlns='urn:xmpp:jingle:1' " + "action='session-initiate' sid='2227053353' " + "initiator='user@gmail.com/chromiumsy5C6A652D'><content " + "name='chromoting' creator='initiator'><description " + "xmlns='google:remoting'><control transport='stream' version='2'/><event " + "transport='stream' version='2'/><video transport='stream' version='2' " + "codec='vp8'/><initial-resolution width='800' height='600'/>" + "<authentication><auth-token>j7whCMii0Z0AAPwj7whCM/j7whCMii0Z0AAPw=" + "</auth-token></authentication></description><transport " + "xmlns='http://www.google.com/transport/p2p'/></content></jingle>" + "<error code='501' type='cancel'><feature-not-implemented " + "xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error>" + "</iq>"; + scoped_ptr<XmlElement> source_message( + XmlElement::ForStr(kTestSessionInitiateErrorMessage)); + ASSERT_TRUE(source_message.get()); + + EXPECT_FALSE(JingleMessage::IsJingleMessage(source_message.get())); + + JingleMessage message; + std::string error; + EXPECT_FALSE(message.ParseXml(source_message.get(), &error)); + EXPECT_FALSE(error.empty()); +} + } // namespace protocol } // namespace remoting |