Attachment download doesn't match upload

Discussion in 'General Topics' started by TheWindBringeth, Aug 11, 2015.

  1. TheWindBringeth

    TheWindBringeth Registered Member

    Joined:
    Feb 29, 2012
    Posts:
    2,088
    In reply <post now deleted>, I HTTPS uploaded a file named PastedUserPrefsExporter_0.1.txt. It is an HTML file with Javascript, given a .txt extension. The upload looked OK to me.

    However, the download doesn't match the upload (I downloaded with two different browsers).

    Edit: I downloaded a couple of other, older, attachments which consisted of HTML+Javascript content with a .txt extension. I see some reshuffling in at least some of them as well. These are being retrieved via HTTPS, btw. I'm not sure at the point, but it looks as though it may be an attempt to move <script></script> blocks out of the head section.
     
    Last edited: Aug 12, 2015
  2. TheWindBringeth

    TheWindBringeth Registered Member

    Joined:
    Feb 29, 2012
    Posts:
    2,088
    OK, I think I narrowed things down. I upload this as ReorderTest.txt:
    Code:
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Reorder Test</title>
    <style type="text/css">
    body {background-color: #dddddd;}
    </style>
    <script type="text/javascript">
    function headScriptBlkFunc ()
    {
      document.write("4 5 6 ");
    }
    </script>
    </head>
    <body>
    <noscript><div>Needs javascript</div></noscript>
    1 2 3 
    <script type="text/javascript">
    headScriptBlkFunc();
    </script>
    7 8 9
    </body>
    </html>
    
    and when I download it I get this:
    Code:
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Reorder Test</title>
    <style type="text/css">
    body {background-color: #dddddd;}
    </style>
    </head>
    <body>
    <noscript><div>Needs javascript</div></noscript>
    1 2 3
    7 8 9
    <script type="text/javascript">
    function headScriptBlkFunc ()
    {
      document.write("4 5 6 ");
    }
    </script><script type="text/javascript">
    headScriptBlkFunc();
    </script></body>
    </html>
    
     
  3. LowWaterMark

    LowWaterMark Administrator

    Joined:
    Aug 10, 2002
    Posts:
    17,877
    Location:
    New England
    We use a XenForo add-on which helps with page load performance by deferring the loading of scripts to the bottom of the page. (There are performance recommendations as to why that is a good thing. And, it does actually result in faster page loading.)

    Anyway, that modification does exactly what you described, but, it's supposed to only do that for real script code in the forum webpages, not the downloading of attached text files. But, apparantly it also sees those text files as HTML pages... as they download, they look like HTML webpages with embedded scripts, so, it was altering those, too.

    We got an update from the author to resolve this issue. I tested it and the files no longer get resequenced.

    Note that the uploaded files are stored fine. This add-on only runs dynamically as pages are rendered. So, if you retest the files you've uploaded, they should all download fine now.
     
  4. TheWindBringeth

    TheWindBringeth Registered Member

    Joined:
    Feb 29, 2012
    Posts:
    2,088
    Thank you for your efforts, and ditto to any others involved. That was fast, and successful AFAICT. I searched for and read some material on such optimizations.