mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Fix exception when OpenGraph tag values are ints
This commit is contained in:
parent
e78167c94b
commit
81d49cbb07
1
changelog.d/6334.feature
Normal file
1
changelog.d/6334.feature
Normal file
@ -0,0 +1 @@
|
|||||||
|
Limit the length of data returned by url previews, to prevent DoS attacks.
|
@ -274,7 +274,8 @@ class PreviewUrlResource(DirectServeResource):
|
|||||||
# filter out any stupidly long values
|
# filter out any stupidly long values
|
||||||
keys_to_remove = []
|
keys_to_remove = []
|
||||||
for k, v in og.items():
|
for k, v in og.items():
|
||||||
if len(k) > OG_TAG_NAME_MAXLEN or len(v) > OG_TAG_VALUE_MAXLEN:
|
# values can be numeric as well as strings, hence the cast to str
|
||||||
|
if len(k) > OG_TAG_NAME_MAXLEN or len(str(v)) > OG_TAG_VALUE_MAXLEN:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Pruning overlong tag %s from OG data", k[:OG_TAG_NAME_MAXLEN]
|
"Pruning overlong tag %s from OG data", k[:OG_TAG_NAME_MAXLEN]
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user