RealRaven2000 / FiltaQuilla

Adds many new mail filter actions to Thunderbird
http://quickfilters.quickfolders.org/filtaquilla.html
GNU General Public License v3.0
88 stars 17 forks source link

JavaScript error: chrome://filtaquilla/content/filtaquilla-util.js, line 574: InternalError: too much recursion #302

Open pschonmann opened 1 month ago

pschonmann commented 1 month ago

Hi im using thunderbird on linux mint

ii  thunderbird                                                 1:115.15.0+build1-0ubuntu0.22.04.1                amd64        Email, RSS and newsgroup client with integrated spam filter

When i start, it starts too long and console give me lots of these errors

JavaScript error: chrome://filtaquilla/content/filtaquilla-util.js, line 574: InternalError: too much recursion
JavaScript error: chrome://filtaquilla/content/filtaquilla-util.js, line 574: InternalError: too much recursion
JavaScript error: chrome://filtaquilla/content/filtaquilla-util.js, line 574: InternalError: too much recursion
JavaScript error: chrome://filtaquilla/content/filtaquilla-util.js, line 574: InternalError: too much recursion
JavaScript error: chrome://filtaquilla/content/filtaquilla-util.js, line 574: InternalError: too much recursion
console.log: "FiltaQuilla [logTime init]\n" "bodyMimeMatch() : No BodyParts could be extracted."
console.log: "FiltaQuilla\n %cbodyRegex RESULT: false" "color:white;background:rgb(0,100,0)" "\n search term: Body matches .*https\\:\\/\\/subdomain\\.domain\\.cz\\/dashboard\\/snapshot\\/[\\r\\n]+V DOMECKu.*"
console.log: "FiltaQuilla 22:26:17.630  [167 ms]   \n" "NetUtil.readInputStreamToString FAILED\nStreaming the message in folder Inbox failed.\nMatching body impossible." ({})
console.log: "FiltaQuilla\n %cbodyRegex RESULT: false" "color:white;background:rgb(0,100,0)" "\n search term: Body matches .*https\\:\\/\\/subdomain\\.domain\\.cz\\/dashboard\\/snapshot\\/[\\r\\n]+V DOMECKu.*"
console.log: "FiltaQuilla 22:26:17.672  [42 ms]   \n" "NetUtil.readInputStreamToString FAILED\nStreaming the message in folder Inbox failed.\nMatching body impossible." ({})
console.log: "FiltaQuilla\n %cbodyRegex RESULT: false" "color:white;background:rgb(0,100,0)" "\n search term: Body matches .*https\\:\\/\\/subdomain\\.domain\\.cz\\/dashboard\\/snapshot\\/[\\r\\n]+V DOMECKu.*"
console.log: "FiltaQuilla 22:26:17.829  [157 ms]   \n" "bodyMimeMatch() : No BodyParts could be extracted."
console.log: "FiltaQuilla\n %cbodyRegex RESULT: false" "color:white;background:rgb(0,100,0)" "\n search term: Body matches .*https\\:\\/\\/subdomain\\.domain\\.cz\\/dashboard\\/snapshot\\/[\\r\\n]+V DOMECKu.*"
console.log: "FiltaQuilla 22:26:17.890  [61 ms]   \n" "bodyMimeMatch() : No BodyParts could be extracted."
console.log: "FiltaQuilla\n %cbodyRegex RESULT: false" "color:white;background:rgb(0,100,0)" "\n search term: Body matches .*https\\:\\/\\/subdomain\\.domain\\.cz\\/dashboard\\/snapshot\\/[\\r\\n]+V DOMECKu.*"
console.log: "FiltaQuilla 22:26:17.964  [74 ms]   \n" "NetUtil.readInputStreamToString FAILED\nStreaming the message in folder Inbox failed.\nMatching body impossible." ({})

Thanks for check

RealRaven2000 commented 1 month ago

Can you export your filter?

image

(the functionality to export is part of the quickFilters Add-on)

Also, try to switch the filter to execute "after Junk classification"

pschonmann commented 1 month ago

I want to check mail BEFORE junk, but ill try.

{
  "accountName": "imap://petr.schonmann%40domain.cz@mail.domain.cz",
  "rootFolderURL": "imap://petr.schonmann%40domain.cz@mail.domain.cz",
  "date": "2024-10-04T09:21:20.867Z",
  "filters": [
    {
      "filterName": "VADNE MAILY SE SNAPSHOTY",
      "filterDesc": "",
      "filterType": 17,
      "temporary": false,
      "actionCount": 1,
      "enabled": true,
      "actionList": [
        {
          "type": 17,
          "strValue": "$label1"
        }
      ],
      "searchTerms": [
        {
          "attrib": -2,
          "op": 19,
          "value": {
            "attrib": -2,
            "str": ".*https\\:\\/\\/subdomain\\.domain\\.cz\\/dashboard\\/snapshot\\/[\\r\\n]+V DOMECKu.*"
          },
          "booleanAnd": true,
          "customId": "filtaquilla@mesquilla.com#bodyRegex",
          "beginsGrouping": false,
          "endsGrouping": false
        }
      ]
    }
  ]
}
RealRaven2000 commented 2 weeks ago

thanks for posting the error log, I think one of the main problems is that the message cannot be read (streamed):

NetUtil.readInputStreamToString FAILED
Streaming the message in folder Inbox failed.
Matching body impossible.

it would be interesting to me whether the same error happens if you rolled back to FiltaQuilla 4.0 ?

there were some changes affecting streaming maybe it affects your mail system.

The old code determines the message size first:

    let hasOffline = folder.hasMsgOffline(aMsgHdr.messageKey);
    let messageSize = hasOffline
      ? aMsgHdr.offlineMessageSize
      : aMsgHdr.messageSize;
    var data;
    if (!messageSize) {
      if (FiltaQuilla.Util.isDebug) {
        console.log(`Filter could not read message size for ${aMsgHdr.mime2DecodedSubject}! Offline = ${hasOffline}`, aMsgHdr, folder);
      }
      if (hasOffline) {
        messageSize = aMsgHdr.messageSize;
        if (FiltaQuilla.Util.isDebug) {
          console.log(`trying to fallback to messageSize: ${messageSize}`);
        }
        if (!messageSize) {
          return false;
        }
      }
    }

it then streams the data in a single chunk:

    let stream = folder.getMsgInputStream(aMsgHdr, {});
    try {
      data = NetUtil.readInputStreamToString(stream, messageSize);

Since 4.1 we use this code, after recommendation by a Thunderbird Core developer:

    let stream = folder.getMsgInputStream(aMsgHdr, {});
    let isStreamError = false;
    try {
      // [issue #260]
      data = "";
      let available;
      while (available = stream.available() ) {
        data += NetUtil.readInputStreamToString(stream, available);
      }
    } 

this is where the error is thrown. Would it help for your issue?

Also for investigating the recursion problem, can you enable debug mode and the switch "debug.mimeBody", here?

image

if you capture the debug log then we might get more info why there is too much recursion happening.

RealRaven2000 commented 1 week ago

Seems this is triggered by a regex finding multiple matches in a non-global regex. So any regular expression that doesn't end with /g

Here is a version that might fix it:

filtaquilla-4.2.1pre8.zip

Will probably release this soon.