Skip to content

[3.x] Fix binary checks (port of #15900) to make sure textual-ish files can be edited #15901

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

Merged
merged 1 commit into from
Nov 18, 2021

Conversation

Mark-H
Copy link
Collaborator

@Mark-H Mark-H commented Nov 11, 2021

What does it do?

This adds a whitelist of mime types that should be editable. Port of #15900 for 3.x.

Also corrects the logic for calls to isFileBinary; a binary file is one that consists of garbage text and should not be edited, but that logic had been flipped in 3.x.

Why is it needed?

This check is used to decide wether or not the files tree should offer the edit option. Some of these, especially json and xml, are not offered the edit option regardless of exension.

How to test

Add a file with some JSON content, for example:

{
   "style_formats":[
      {
         "title":"Red text",
         "inline":"span",
         "styles":{
            "color":"#ff0000"
         }
      }
   ]
}

Note that in the files tree it is not editable (clicking it does nothing).

Apply the patch, and note that now it can be edited.

Related issue(s)/PR(s)

None, was reported in slack and I went straight from debugging to fixing.

…les can be edited

This adds a whitelist of mime types that should be editable.

Also corrects the logic for calls to isFileBinary; a binary file is one that consists of garbage text and should not be edited, but that logic had been flipped in 3.x.
@Mark-H Mark-H added this to the v3.0.0-beta2 milestone Nov 11, 2021
@Mark-H Mark-H requested a review from opengeek as a code owner November 11, 2021 16:24
@cla-bot cla-bot bot added the cla-signed CLA confirmed for contributors to this PR. label Nov 11, 2021
@opengeek opengeek merged commit e79da1b into modxcms:3.x Nov 18, 2021
@Mark-H Mark-H deleted the 3.x-fix-isbinary branch January 19, 2022 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed CLA confirmed for contributors to this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants