Ylianst / MeshCentral

A complete web-based remote monitoring and management web site. Once setup you can install agents and perform remote desktop session to devices on the local network or over the Internet.
https://meshcentral.com
Apache License 2.0
4.08k stars 549 forks source link

editing windows text files in files web ui, generates new lines as linux lines #6365

Closed si458 closed 3 weeks ago

si458 commented 3 weeks ago

Describe the bug when editing a windows text file in the file UI, when you save it appears to be saving the new lines as linux new lines?

To Reproduce Steps to reproduce the behavior:

  1. create windows text file using notepad++ (enable show end of line)
  2. file is created with windows end of lines
  3. edit the text file in the web ui of meshcentral,
  4. recheck file on windows machine in notepad++
  5. end of lines now show as linux new lines instead?

Expected behavior file should be saved as is with new lines intact

Screenshots If applicable, add screenshots to help explain your problem.

Server Software (please complete the following information):

Client Device (please complete the following information):

Remote Device (please complete the following information):

Additional context Add any other context about the problem here.

Your config.json file

{
  "$schema": "https://raw.githubusercontent.com/Ylianst/MeshCentral/master/meshcentral-config-schema.json",
  "__comment1__": "This is a simple configuration file, all values and sections that start with underscore (_) are ignored. Edit a section and remove the _ in front of the name. Refer to the user's guide for details.",
  "__comment2__": "See node_modules/meshcentral/sample-config-advanced.json for a more advanced example.",
  "settings": {
    "_cert": "myserver.mydomain.com",
    "_WANonly": true,
    "_LANonly": true,
    "_sessionKey": "MyReallySecretPassword1",
    "_port": 443,
    "_aliasPort": 443,
    "_redirPort": 80,
    "_redirAliasPort": 80
  },
  "domains": {
    "": {
      "_title": "MyServer",
      "_title2": "Servername",
      "_minify": true,
      "_newAccounts": true,
      "_userNameIsEmail": true
    }
  },
  "_letsencrypt": {
    "__comment__": "Requires NodeJS 8.x or better, Go to https://letsdebug.net/ first before trying Let's Encrypt.",
    "email": "myemail@mydomain.com",
    "names": "myserver.mydomain.com",
    "production": false
  }
}
PathfinderNetworks commented 3 weeks ago

I just tested this as I'm running MeshCentral on a Windows Server (Server 2022 VM). Under my Windows Server version it's not changing the end of lines. When I edit the file directly with Notepad++ it adds a LF. When I edit that same file in the MeshCentral WEB GUI file editor it also adds a LF when viewing the resulting edit in Notepad++

So must just be something coming from running MeshCentral under Linux?

si458 commented 3 weeks ago

If u use normal notepad and write something, then open it inside notepad++ u can see its CR LF

But if u then edit it in the webui. It then saves back to LF

I'm in the process of adding in the option in the Web ui in the edit to let u change the line breaks between windows/mac/linux :)

Our custom software looks for cr lf and when I edit in the ui, it's saving as lf which then goofs up our custom software haha

si458 commented 3 weeks ago

When u copy the data into text area it changes \r\n to just \n

Which then in turn when u save the file is using \n instead of the original \r\n

PathfinderNetworks commented 3 weeks ago

You are right, I do see that now. It removes the carriage return (CR) even under my Windows Server version.

si458 commented 3 weeks ago

I was going to get it default to whatever OS the remote device was running originally OR If the text file contained \r\n then just use windows

Then, I decided, no, let u the end user pick but default to windows :)

then it will just replace \n with \r\n or \n or \r

Depending on what u wanted to use!

si458 commented 3 weeks ago

all done! https://github.com/Ylianst/MeshCentral/commit/6fe30b7730fbdb7e4e285d91ec54b8a6fa9c5ce1 Screenshot 2024-09-08 at 20-12-29 DESKTOP-LTSAD3V - myothergroup - MyRemoteAgent Screenshot 2024-09-08 at 20-12-20 DESKTOP-LTSAD3V - myothergroup - MyRemoteAgent Screenshot 2024-09-08 at 20-12-12 DESKTOP-LTSAD3V - myothergroup - MyRemoteAgent

you can now specify what line break to use before saving, and it remembers in your browser/session too!