Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File block retains href after uploading an unsupported file type causing block to encounter an error after page refresh #8155

Closed
talldan opened this issue Jul 24, 2018 · 2 comments
Labels
[Block] File Affects the File Block [Feature] Blocks Overall functionality of blocks [Feature] Drag and Drop Drag and drop functionality when working with blocks [Type] Bug An existing feature does not function as intended

Comments

@talldan
Copy link
Contributor

talldan commented Jul 24, 2018

Describe the bug
Refreshing the page after a File Block after an invalid file type has been added results in a block in an erroneous state

Related to umbrella issue #8119, since this happens when the file block edit componentDidMount and triggers particular transitions in state.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new post
  2. Drag and drop a file with an unsupported file type (.exe, .dmg, .json etc.)
  3. Observe that a file block is created and displays an error "Sorry, this file type is not permitted for security reasons."
  4. Update/Save the post
  5. Refresh the page
  6. Observe that 'This block has encountered an error and cannot be previewed.' is displayed where the file block once was.

Expected behavior
The file block should still be displayed and should probably not display any kind of error.

Screenshots
screen shot 2018-07-24 at 10 42 13 am

Desktop (please complete the following information):

  • OS: Mac OS
  • Browser: Chrome
  • Version: 67

Additional context

  • Discovered while testing File block: Handle drag-and-drop errors #8066, but not caused by it
  • This is caused by the file block retaining the 'href' attribute for a blob that no longer exists after previously encountering an error. When mounting after the page reload the file variable is undefined. The call to mediaUpload then results in an error:
    const file = getBlobByURL( href );
    mediaUpload( {
    allowedType: '*',
    filesList: [ file ],
    onFileChange: ( [ media ] ) => this.onSelectFile( media ),
    onError: ( message ) => {
    this.setState( { hasError: true } );
    noticeOperations.createErrorNotice( message );
    },
    } );
@talldan talldan added [Type] Bug An existing feature does not function as intended [Feature] Blocks Overall functionality of blocks [Feature] Drag and Drop Drag and drop functionality when working with blocks labels Jul 24, 2018
@arunsathiya
Copy link
Contributor

Was able to reproduce a similar error Sorry, this file type is not permitted for security reasons. when uploading a .mkv file - #8873.

Was not able to reproduce an erroneous state of the block on the output though.

@mtias mtias added the [Block] File Affects the File Block label Oct 27, 2018
@jorgefilipecosta
Copy link
Member

Hi @talldan, thank you for reporting this issue, @arunsathiya thank you for the tests you performed. I was also not able to replicate a block crash in my tests, so I'm going to close this issue as I think it got fixed meanwhile.
To not that when dragging an invalid file to the editor without previously adding a file block, the block keeps a transient URL, and that should be fixed but it is a different issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] File Affects the File Block [Feature] Blocks Overall functionality of blocks [Feature] Drag and Drop Drag and drop functionality when working with blocks [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants