[Bug] Downloading revisions not working

I made a similar post about this one (https://lemmy.world/post/11134086) and it happened again, and hopefully the Dev can notice. (ping please)

Here’s the error that Perchance throws when I try to download revisions from https://perchance.org/power-generator-manager-10k-milestone:

Uncaught URIError: URI malformed
at decodeURI (see image)

EDIT: After some later investigation, I’ve found out that this does NOT affect earlier revisions (see this comment: https://lemmy.world/comment/8770044)

@perchance

  • 🎲VioneTM
    link
    fedilink
    English
    1
    edit-2
    3 months ago

    On that note, I duplicated the hub and deleted the old one, it did resolve the revisions problem (though the view count reset).

    • BluePower
      link
      English
      13 months ago

      What? With a hub that had over a thousand views? That’s remarkable.

      Also @[email protected], if there’s a way to backup and erase all the revisions somehow 🤔

      • 🎲VioneTM
        link
        fedilink
        English
        2
        edit-2
        3 months ago
        function checkForMalformedRevs(patch, loglabel, startFrom) {
          let text;
          let errors = []
          let dateRegex = [/^.* ([0-9][0-9]:[0-9][0-9]:[0-9][0-9]) GMT+.*/g, "$1"];
          console.log('[' + loglabel + ']', Date().replace(/ \(GMT+.*\)/g, ""), 'Check Started.');
          patch.forEach((a,i) => {
            if (i < startFrom) return;
            let pi = diffStuff._patchesToRevision(patch, i);
            let x = 0;
            let offset = 0;
            try {
              for (x = 0; x < pi.length; x += 100) {
                offset = (!!pi.substring(x, x + 100).match(/%.$/g) * 1) + (!!pi.substring(x, x + 100).match(/%$/g) * 2); // checks if there's any "chopped" URI characters at the end of the chunk to prevent `URI malformed` errors just because of that
                text = pi.substring(x, x + 100 + offset)
                let decoded = decodeURI(text);
                decoded = '';
                text = '';
                x += offset;
                offset = 0;
              }
              console.log('[' + loglabel + ']', Date().replace(...dateRegex), 'Checked:', i);
              x = 0;
            } catch (err) {
              console.error('[' + loglabel + ']', Date().replace(...dateRegex), 'Error:', i, 'at chunk', x + '-' + (x + 100 + offset), 'of', pi.length, err, 'Chunk Text:', text);
              errors.push({date: new Date(diffStuff.patches[i].creationTime), log: loglabel, revisionId: i, chunkRange: `${x}-${x + 100 + offset}`, revisionLength: pi.length, text: text});
              
            }
          })
          console.log('[' + loglabel + ']', Date().replace(/ \(GMT+.*\)/g, ""), 'Check Complete.');
          console.table(errors, ['date', 'text']);
        }
        checkForMalformedRevs(diffStuff.modelTextPatches, 'modelTextPatches')
        // checkForMalformedRevs(diffStuff.outputTemplatePatches, 'outputTemplatePatches')
        

        Here is a code that also outputs the Date of the Revision as well as the Text that was throwing the error neatly in a table. It seems ONLY the modelTextPatches are throwing the malformeds.

        • BluePower
          link
          English
          13 months ago

          Oooh nice! I’ll test that later, and I’ll improve it even more when needed.