You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to open file for editing with "Edit in Plain Text editor", whatever is the actual content of the file, the content in text editor is just one word - "false".
After some research I came to these lines of source code, and there is, in my opinion something wrong:
since in line No 99 it is strict mode used, mb_detect_encoding() function will return either one of the encodings given in the input list, or FALSE; in case of FALSE or any valid result, the condition on line No 100 will NEVER evaluate to TRUE (some times in history, here was simple comparison, and in this case it evaluated to TRUE in case if $encoding holds false value);
in case if iconv() function fails on line No 104 (as it is in may case; I can read error logs in NC logs), according to iconv() documentation it returns FALSE and this is how on line No 107 file's content is converted to single word "false".
as per this answer on stackoverflow.com, most probably on line No 99 the passed in encoding list is not correct/supported by mb_detect_encoding() (here I agree that PHP documentation is a bit awkward - encodings currently implemented in mb_detect_encoding() are documented under mb_detect_order())
In my case valid UTF-8 content is detected as WINDOWS-1257, and then iconv() fails to convert actual UTF8 content treated as WINDOWS-1257 to UTF8. There is an error log entry in NC logs: Error: iconv(): Detected an illegal character in input string at /var/www/{******}/apps/files_texteditor/lib/Controller/FileHandlingController.php#104
The text was updated successfully, but these errors were encountered:
The file was created with files_texteditor, I added some text, including some accentuated chars, euro symbol, etc.
At this point, I still could open it without any error.
I then added some pipe symbols (from CP437 encoding) and from then I couldn't open the file again, just the "false" at the begining of the file.
I checked on the filesystem, the content of the file is complete, the reported encoding is UTF-8.
Actually, adding some traces to files_texteditor/lib/Controller/FileHandlingController.php,
I saw that my file is detected as Windows-1252 by mb_detect_encoding instead of UTF-8
I also tried to force UTF-8, and in this case, the file is displayed correctly:
When I try to open file for editing with "Edit in Plain Text editor", whatever is the actual content of the file, the content in text editor is just one word - "false".
After some research I came to these lines of source code, and there is, in my opinion something wrong:
files_texteditor/lib/Controller/FileHandlingController.php
Lines 99 to 107 in 6b4e0e1
mb_detect_encoding()
function will return either one of the encodings given in the input list, or FALSE; in case of FALSE or any valid result, the condition on line No 100 will NEVER evaluate to TRUE (some times in history, here was simple comparison, and in this case it evaluated to TRUE in case if$encoding
holds false value);iconv()
function fails on line No 104 (as it is in may case; I can read error logs in NC logs), according toiconv()
documentation it returns FALSE and this is how on line No 107 file's content is converted to single word "false".mb_detect_encoding()
(here I agree that PHP documentation is a bit awkward - encodings currently implemented inmb_detect_encoding()
are documented undermb_detect_order()
)In my case valid UTF-8 content is detected as WINDOWS-1257, and then
iconv()
fails to convert actual UTF8 content treated as WINDOWS-1257 to UTF8. There is an error log entry in NC logs:Error: iconv(): Detected an illegal character in input string at /var/www/{******}/apps/files_texteditor/lib/Controller/FileHandlingController.php#104
The text was updated successfully, but these errors were encountered: