Bug #1723

Ide::IdePaste(String& data) shall be reviewed, it stop when file size reache 5000000 B without warning

Added by Abdelghani Omari over 7 years ago. Updated over 7 years ago.

Status:ApprovedStart date:05/17/2017
Priority:NormalDue date:
Assignee:Miroslav Fidler% Done:

0%

Category:IDESpent time:-
Target version:-

Description

In this function I noticed two things:
  - it stops at 5000000 without warning
  - I do not understand the condition (if(len > 5000000 || data.GetLength() + len < 5000000))
why (len > 5000000) ? perhaps it will be (len < 5000000)
- 5000000 as limit is too small.

void Ide::IdePaste(String& data)
{
    data.Clear();
    if(AcceptFiles(Clipboard())) {
        Vector<String> s = GetFiles(Clipboard());
        for(int i = 0; i < s.GetCount(); i++)
            if(FileExists(s[i]) && IsTextFile(s[i], 10000)) {
                int64 len = GetFileLength(s[i]);
                if(len > 5000000 || data.GetLength() + len < 5000000)
                    data.Cat(LoadFile(s[i]));
            }
    }
}

here the patched function:


void Ide::IdePaste(String& data)
{
    data.Clear();
    if(AcceptFiles(Clipboard())) {
        Vector<String> s = GetFiles(Clipboard());
        for(int i = 0; i < s.GetCount(); i++)
            if(FileExists(s[i]) && IsTextFile(s[i], 10000)) {
                int64 len = GetFileLength(s[i]);
                if( data.GetLength() + len > 104857600) {
                    Exclamation("The file size reaches the limit of 100 MB.");
                    return;
                }

                data.Cat(LoadFile(s[i]));
            }
    }
}

History

#1 Updated by Abdelghani Omari over 7 years ago

  • Status changed from New to Patch ready

#2 Updated by Abdelghani Omari over 7 years ago

  • Description updated (diff)

#3 Updated by Miroslav Fidler over 7 years ago

  • Status changed from Patch ready to Approved

Also available in: Atom PDF