mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 15:05:11 +00:00
[MOD] Be stringent about OIDs, use fmemopen
This commit is contained in:
parent
55674c369b
commit
3366fcb759
8 changed files with 76 additions and 122 deletions
|
|
@ -186,6 +186,10 @@ IQResult(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
|
||||
jid = ParseeLookupJID(from);
|
||||
from_matrix = ParseeGetBridgedUser(args, stanza);
|
||||
Log(LOG_DEBUG,
|
||||
"Setting the avatar of '%s' to %s",
|
||||
from_matrix, mxc
|
||||
);
|
||||
ASSetAvatar(args->config, from_matrix, mxc);
|
||||
|
||||
Free(mxc);
|
||||
|
|
@ -224,12 +228,13 @@ IQResult(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
|
||||
/* Get the base64, decode it, and shove it in a nicely put
|
||||
* MXC address */
|
||||
base64 = data->data;
|
||||
base64 = TrimBase64(data->data);
|
||||
b64len = base64 ? strlen(base64) : 0;
|
||||
length = Base64DecodedSize(base64, b64len);
|
||||
|
||||
bdata = Base64Decode(base64, b64len);
|
||||
datastream = StrStreamReaderN(bdata, length);
|
||||
Log(LOG_DEBUG, "(%dB @ %p) = %p (%d)", b64len, base64, bdata, length);
|
||||
mxc = ASUpload(
|
||||
args->config,
|
||||
datastream,
|
||||
|
|
@ -237,6 +242,7 @@ IQResult(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
tdata ? tdata->data : NULL
|
||||
);
|
||||
Free(bdata);
|
||||
Free(base64);
|
||||
StreamClose(datastream);
|
||||
|
||||
room = ParseeGetBridgedRoom(args, stanza);
|
||||
|
|
@ -247,8 +253,27 @@ IQResult(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
/* TODO: More reliable system for telling the difference appart */
|
||||
if (jid && !StrEquals(from, resource))
|
||||
{
|
||||
from_matrix = ParseeGetBridgedUserI(args, stanza, jid);
|
||||
char *oid = ParseeLookupOID(jid);
|
||||
char *hsh = ParseeSHA256(oid);
|
||||
bool scrambled =
|
||||
oid && StrEquals(jid, HashMapGet(stanza->attrs, "from"));
|
||||
from_matrix = scrambled
|
||||
? ScrambleOID(args, oid)
|
||||
: ParseeGetBridgedUser(args, stanza);
|
||||
|
||||
Log(LOG_DEBUG,
|
||||
"Setting the vCard of '%s'(%s) to %s (%d B)",
|
||||
from_matrix, jid, mxc,
|
||||
length
|
||||
);
|
||||
Log(LOG_DEBUG,
|
||||
"OID=%s[%s]",
|
||||
oid, hsh
|
||||
);
|
||||
|
||||
ASSetAvatar(args->config, from_matrix, mxc);
|
||||
Free(oid);
|
||||
Free(hsh);
|
||||
}
|
||||
else if (room)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue