1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed Execution timeout when handling image data URLs

Discussion in 'Resolved Bug Reports' started by Xon, Dec 4, 2015.

  1. Xon

    Xon Well-Known Member

    XenForo_Helper_Media::_convertMediaLinkToEmbedHtml blindly attempts to convert any text into a media bbcode. This causes ridiculously long execution times if there are a lot of media sites added, and dealing with +20kb of text.

    An 2kb length limit is the practical limit to ensure IE compatibility, while most servers max out at 8kb.

    The media editor appears to sometimes do this for some people. ie the URL; index.php?editor/media where they paste an entire image (as data:image/jpeg;base64,...) into the URL textbox.
    Last edited: Dec 4, 2015
    semprot likes this.
  2. Mike

    Mike XenForo Developer Staff Member

    I suppose this depends exactly how many media sites you have (and the regex structure of them), but I have made some tweaks here that should resolve this:
    • If the URL has a protocol but it's not http or https, immediately abort. (If it doesn't have a protocol, we'll assume someone did "youtube.com/...." and keep checking.
    • Truncate the URL to 8KB before checking. Certainly longer than should really be necessary, but it appears that IE does support URLs longer than 2KB now and other browsers do too.
    eva2000 and Xon like this.

Share This Page