I think I did it correctly, theoretically looks good. I just don't know if `$in{'encoding'}` has to be escaped anyhow. Other than that, it seems ok, as when user passes encoding, it will tell the script to use one.
This is more like server side thing.
We expect that everything that is coming from the editor (CodeMirror) is always UTF-8 encoded. In case, global encoding is set to something different, then UTF-8, we must use the user encoding to properly encode the data and have correct file encoding after all.
[#52019](https://www.virtualmin.com/node/52019)