Theme files cannot be edited when theme's directory has certain characters in it
|Reported by:||trasnam||Owned by:||ryan|
|Component:||Administration||Keywords:||theme editor bracket parenthesis spaces braces has-patch|
Theme files cannot be edited when the theme name contains brackets in the directory name. (For example themename[modification] .)
After the upgrade to 2.0.4, I noticed I can no longer edit any theme files. I get the error, "Sorry, that file cannot be edited." when I hit "Update File" on the theme-editor.php page for any arbitrary file. This also occurs in 2.1 Alpha 2, but does not occur in 2.0.3. Therefore, I believe it is a regression.
After doing some debugging, I noticed that the value for the file I am editing is not the same in both $files and $allowed_files in admin-functions.php (only upon form submission, however). The value in $files has the brackets stripped out, whereas the value in $allowed_files doesn't have the brackets stripped out.
As a result of this, the function validate_file returns a 3, which in turn makes the function validate_file_to_edit return the "Sorry, that file cannot be edited." message.
I haven't yet figured out what causes the brackets to get stripped out, and as such I have renamed the theme directory as a temporary workaround.
I have no problem renaming the directory as a permanent fix, but I think the code should at least check for the brackets and tell the user to give the directory another name. If not, it should handle the bracket just like any other text character without stripping it out.
See this thread for more information:
Change History (19)
- Summary changed from Theme files cannot be edited when theme's directory has brackets in it to Theme files cannot be edited when theme's directory has certain characters in it
in reply to:
8 years ago
- Resolution fixed deleted
- Status changed from closed to reopened