Skip to content
Snippets Groups Projects
Unverified Commit 5570d1c9 authored by Richard van der Hoff's avatar Richard van der Hoff Committed by GitHub
Browse files

Merge pull request #6334 from matrix-org/rav/url_preview_limit_title_2

Fix exception when OpenGraph tag values are ints
parents 02f99906 81d49cbb
No related branches found
No related tags found
No related merge requests found
Limit the length of data returned by url previews, to prevent DoS attacks.
......@@ -278,7 +278,8 @@ class PreviewUrlResource(DirectServeResource):
# filter out any stupidly long values
keys_to_remove = []
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(
"Pruning overlong tag %s from OG data", k[:OG_TAG_NAME_MAXLEN]
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment