diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-04-22 23:02:28 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-04-22 23:02:28 +0900 |
| commit | 211c4ea9f45db6482f76ccc9945ee19fc78f7e9d (patch) | |
| tree | f3e637f9f0af186e8114b95258d9e37d7c766b51 /src | |
| parent | 6ee58e28729f7332c353ea89271eb1e75e5bf0a4 (diff) | |
If no data type tag is used in XML-RPC, treat the data as string.
Diffstat (limited to 'src')
| -rw-r--r-- | src/XmlRpcRequestParserStateImpl.cc | 16 | ||||
| -rw-r--r-- | src/XmlRpcRequestParserStateImpl.h | 6 |
2 files changed, 18 insertions, 4 deletions
diff --git a/src/XmlRpcRequestParserStateImpl.cc b/src/XmlRpcRequestParserStateImpl.cc index 7cf1c5ac..2d406e8e 100644 --- a/src/XmlRpcRequestParserStateImpl.cc +++ b/src/XmlRpcRequestParserStateImpl.cc @@ -168,7 +168,20 @@ void ValueXmlRpcRequestParserState::beginElement stm->pushUnknownElementState(); } } - + +void ValueXmlRpcRequestParserState::endElement +(XmlRpcRequestParserStateMachine* stm, + const std::string& name, + const std::string& characters) +{ + // XML-RPC specification says that if no data type tag is used, the + // data must be treated as string. To prevent from overwriting + // current frame value, we first check it is still null. + if(!stm->getCurrentFrameValue() && !characters.empty()) { + stm->setCurrentFrameValue(String::g(characters)); + } +} + // IntXmlRpcRequestParserState void IntXmlRpcRequestParserState::beginElement @@ -321,6 +334,7 @@ void ArrayValueXmlRpcRequestParserState::endElement const std::string& name, const std::string& characters) { + ValueXmlRpcRequestParserState::endElement(stm, name, characters); stm->popArrayFrame(); } diff --git a/src/XmlRpcRequestParserStateImpl.h b/src/XmlRpcRequestParserStateImpl.h index c73aeb3a..40a1534e 100644 --- a/src/XmlRpcRequestParserStateImpl.h +++ b/src/XmlRpcRequestParserStateImpl.h @@ -121,12 +121,12 @@ class ValueXmlRpcRequestParserState:public XmlRpcRequestParserState { virtual void beginElement(XmlRpcRequestParserStateMachine* stm, const std::string& name, const std::map<std::string, std::string>& attrs); - +protected: virtual void endElement(XmlRpcRequestParserStateMachine* stm, const std::string& name, - const std::string& characters) {} + const std::string& characters); - virtual bool needsCharactersBuffering() const { return false; } + virtual bool needsCharactersBuffering() const { return true; } }; class IntXmlRpcRequestParserState:public XmlRpcRequestParserState { |
