silverstripe-cms
silverstripe-cms copied to clipboard
TinyMCE Unavailable ->web.config reset -> IIS problem
On windows installs the /public/assets/web.config gets overridden with the allowed filetypes for allowed extensions.
Which means that the TinyMCE editor javascript which is located under: /public/assets/_tinymce
will fail because this has the extension of .js which I prefer not to have in my allowed filetypes/extensions for upload.
A solution for this is to generate a web.config file in this directory (/public/assets/_tinymce) with the following content: web.config.txt
Or by placing the TinyMCE editor in a directory not underneath the asets directory hence negating this problem of file types.
@MischaKr's concern about disallowing serving JS files from assets is a sensible one. This would involved adding some sort of exception for the _tinymce folder.
If you're looking for a short term fix, you can actually customise the content of that configuration file by overriding the following template in your project. https://github.com/silverstripe/silverstripe-assets/blob/1/templates/SilverStripe/Assets/Flysystem/PublicAssetAdapter_WebConfig.ss
You can set an extension as allowed in assets, but not as allowed_extensions for uploads. We do this for htaccess.
RewriteCond %{REQUEST_URI} !^[^.]*[^\\/]*\\.(?i:css|js<% loop $AllowedExtensions %>|$Extension<% end_loop %>)$
We just need to add the same rule to the WebConfig.ss file.
<fileExtensions allowUnlisted="false" applyToWebDAV="true">
+ <add fileExtension=".css" allowed="true" />
+ <add fileExtension=".js" allowed="true" />
<% loop $AllowedExtensions %>
<add fileExtension=".{$Extension}" allowed="true" />
<% end_loop %>
</fileExtensions>
Shall we pr this?