Defect #18754
openempty svn logentry crashes revision batch reading
0%
Description
If svn xml log contains logentry without data the revision reading is interruped and no error message is written to redmine logs.
Revisions are read from xml returned from command:
svn log --xml ...
Example:
<?xml version="1.0" encoding="UTF-8"?>
<log>
<logentry
revision="2178">
<author>mkrol</author>
<date>2015-01-02T06:24:51.507749Z</date>
<msg>test commit</msg>
</logentry>
<logentry
revision="2177">
</logentry>
...
logentry for revision 2177 is empty - there is no author, msg and date tags.
But the code assumes that revision, date and msg exist in logentry.
This is the code from lib/redmine/scm/adapters/subversion_adapter.rb, lines 175-196:
begin
doc = parse_xml(output)
each_xml_element(doc['log'], 'logentry') do |logentry|
(...)
revisions << Revision.new({:identifier => logentry['revision'],
:author => (logentry['author'] ? logentry['author']['__content__'] : ""),
:time => Time.parse(logentry['date']['__content__'].to_s).localtime,
:message => logentry['msg']['__content__'],
:paths => paths
})
end
rescue
end
If <msg> does not exist the logentry['msg'] returns nil. The call logentry['msg']['__content__'] becomes nil['__content__'] and exception is thrown (then it is ignored and it is ignored outside loop...).
The existing of logentry['author'] is checked before reading logentry['author']['__content__']. It should be done before reading date and msg also. For example:
revisions << Revision.new({:identifier => logentry['revision'],
:author => (logentry['author'] ? logentry['author']['__content__'] : ""),
:time => (logentry['date'] ? Time.parse(logentry['date']['__content__'].to_s).localtime : nil),
:message => (logentry['msg'] ? logentry['msg']['__content__'] : ""),
:paths => paths
})
Why there are empty revisions in svn log? This is when revision has only files which are not visible for user performing svn log command. Propably it's a rare case.
Files
Related issues