mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add new memo restrictions
This commit is contained in:
committed by
Nik Bougalis
parent
b06bdb83cb
commit
a5297d13c4
@@ -318,13 +318,40 @@ bool isMemoOkay (STObject const& st)
|
||||
{
|
||||
if (!st.isFieldPresent (sfMemos))
|
||||
return true;
|
||||
|
||||
const STArray& memos = st.getFieldArray (sfMemos);
|
||||
// The number 2048 is a preallocation hint, not a hard limit
|
||||
// to avoid allocate/copy/free's
|
||||
Serializer s (2048);
|
||||
st.getFieldArray (sfMemos).add (s);
|
||||
memos.add (s);
|
||||
// FIXME move the memo limit into a config tunable
|
||||
if (s.getDataLength () > 1024)
|
||||
return false;
|
||||
|
||||
for (auto const& memo : memos)
|
||||
{
|
||||
auto memoObj = dynamic_cast <STObject const*> (&memo);
|
||||
|
||||
// Memos array must consist solely of Memo objects
|
||||
if (!memoObj || (memoObj->getFName() != sfMemo))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Memo objects may only contain
|
||||
// MemoType, MemoData, and MemoFormat fields
|
||||
for (auto const& memoElement : *memoObj)
|
||||
{
|
||||
if ((memoElement.getFName() != sfMemoType) &&
|
||||
(memoElement.getFName() != sfMemoData) &&
|
||||
(memoElement.getFName() != sfMemoFormat))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -162,6 +162,7 @@ FIELD (ExpireCode, VL, 10)
|
||||
FIELD (CreateCode, VL, 11)
|
||||
FIELD (MemoType, VL, 12)
|
||||
FIELD (MemoData, VL, 13)
|
||||
FIELD (MemoFormat, VL, 14)
|
||||
|
||||
// account
|
||||
FIELD (Account, ACCOUNT, 1)
|
||||
|
||||
Reference in New Issue
Block a user