Skip to content

Commit

Permalink
Fix RecordingRule::ToMap to not lose data.
Browse files Browse the repository at this point in the history
There is one field in this map whose value is presented as a single
UTF16 character, and is likely already overflowing that value. To
prevent changes to existing usage, a new field were added to present
the values in a different way. It has had a "<id>_str" field added to
the map that presents the number as a string so there is no
possibility of overflow.  I.E. The chanid field might be presented as
the four character string "1538" instead of a one character string
containing QChar(1538).

Fixes #342
  • Loading branch information
linuxdude42 committed Mar 18, 2021
1 parent 15018d3 commit 71249dd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
29 changes: 15 additions & 14 deletions mythtv/libs/libmythtv/recordingrule.cpp
Expand Up @@ -541,7 +541,7 @@ bool RecordingRule::Delete(bool sendSig)
return true;
}

void RecordingRule::ToMap(InfoMap &infoMap) const
void RecordingRule::ToMap(InfoMap &infoMap, uint date_format) const
{
if (m_title == "Default (Template)")
{
Expand All @@ -566,17 +566,18 @@ void RecordingRule::ToMap(InfoMap &infoMap) const
infoMap["callsign"] = m_station;

QDateTime starttm(m_startdate, m_starttime, Qt::UTC);
infoMap["starttime"] = MythDate::toString(starttm, MythDate::kTime);
infoMap["starttime"] = MythDate::toString(starttm, date_format | MythDate::kTime);
infoMap["startdate"] = MythDate::toString(
starttm, MythDate::kDateFull | MythDate::kSimplify);
starttm, date_format | MythDate::kDateFull | MythDate::kSimplify);

QDateTime endtm(m_enddate, m_endtime, Qt::UTC);
infoMap["endtime"] = MythDate::toString(endtm, MythDate::kTime);
infoMap["endtime"] = MythDate::toString(endtm, date_format | MythDate::kTime);
infoMap["enddate"] = MythDate::toString(
endtm, MythDate::kDateFull | MythDate::kSimplify);
endtm, date_format | MythDate::kDateFull | MythDate::kSimplify);

infoMap["inetref"] = m_inetref;
infoMap["chanid"] = m_channelid;
infoMap["chanid"] = QChar(m_channelid);
infoMap["chanid_str"] = QString::number(m_channelid);
infoMap["channel"] = m_station;

QDateTime startts(m_startdate, m_starttime, Qt::UTC);
Expand Down Expand Up @@ -607,20 +608,20 @@ void RecordingRule::ToMap(InfoMap &infoMap) const


infoMap["timedate"] = MythDate::toString(
startts, MythDate::kDateTimeFull | MythDate::kSimplify) + " - " +
MythDate::toString(endts, MythDate::kTime);
startts, date_format | MythDate::kDateTimeFull | MythDate::kSimplify) + " - " +
MythDate::toString(endts, date_format | MythDate::kTime);

infoMap["shorttimedate"] =
MythDate::toString(
startts, MythDate::kDateTimeShort | MythDate::kSimplify) + " - " +
MythDate::toString(endts, MythDate::kTime);
startts, date_format | MythDate::kDateTimeShort | MythDate::kSimplify) + " - " +
MythDate::toString(endts, date_format | MythDate::kTime);

if (m_type == kDailyRecord || m_type == kWeeklyRecord)
{
QDateTime ldt =
QDateTime(MythDate::current().toLocalTime().date(), m_findtime,
Qt::LocalTime);
QString findfrom = MythDate::toString(ldt, MythDate::kTime);
QString findfrom = MythDate::toString(ldt, date_format | MythDate::kTime);
if (m_type == kWeeklyRecord)
{
int daynum = (m_findday + 5) % 7 + 1;
Expand All @@ -642,17 +643,17 @@ void RecordingRule::ToMap(InfoMap &infoMap) const
if (m_nextRecording.isValid())
{
infoMap["nextrecording"] = MythDate::toString(
m_nextRecording, kDateFull | kAddYear);
m_nextRecording, date_format | kDateFull | kAddYear);
}
if (m_lastRecorded.isValid())
{
infoMap["lastrecorded"] = MythDate::toString(
m_lastRecorded, kDateFull | kAddYear);
m_lastRecorded, date_format | kDateFull | kAddYear);
}
if (m_lastDeleted.isValid())
{
infoMap["lastdeleted"] = MythDate::toString(
m_lastDeleted, kDateFull | kAddYear);
m_lastDeleted, date_format | kDateFull | kAddYear);
}

infoMap["ruletype"] = toString(m_type);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/recordingrule.h
Expand Up @@ -58,7 +58,7 @@ class MTV_PUBLIC RecordingRule
void UseTempTable(bool usetemp, const QString& table = "record_tmp");
static unsigned GetDefaultFilter(void);

void ToMap(InfoMap &infoMap) const;
void ToMap(InfoMap &infoMap, uint date_format = 0) const;

AutoExpireType GetAutoExpire(void) const
{ return m_autoExpire ? kNormalAutoExpire : kDisableAutoExpire; }
Expand Down

0 comments on commit 71249dd

Please sign in to comment.