-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to jsoncpp as our json library #1005
Conversation
* Load messages from the Resources.resw file * Display a message when we fail to parse the settings on an initial parse, or on a reload. * Unfortunately, the dialog is styled incorrectly when the app theme is opposite the system theme. This can result in the button being invisible.
…or-dialog # Conflicts: # src/cascadia/CascadiaPackage/Resources/en-US/Resources.resw
# Conflicts: # src/cascadia/TerminalApp/App.cpp
They're no longer ordered, which I hate, but we'll live with.
Involves moving serialization out of AppKeyBindings, because all we have is a cppwinrt type, and Json::Value is not a cppwinrt type
# Conflicts: # src/cascadia/TerminalApp/App.cpp # src/cascadia/TerminalApp/App.h # src/cascadia/TerminalApp/AppKeyBindings.cpp # src/cascadia/TerminalApp/AppKeyBindings.h # src/cascadia/TerminalApp/CascadiaSettingsSerialization.cpp # src/cascadia/TerminalApp/ColorScheme.cpp # src/cascadia/TerminalApp/GlobalAppSettings.cpp # src/cascadia/TerminalApp/Profile.cpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am disappointed I can't block my own PR
@zadjii-msft Just a note about jsoncpp - Our open source scanners report two issues with version 1.8.4. (I think this is the version that you are using) https://www.cvedetails.com/cve/CVE-2018-17850/ Another reference - https://tools.cisco.com/security/center/viewAlert.x?alertId=58971 Just fyi - I saw jsoncpp it rang a bell. |
Thanks for keeping an eye out, @dlong11! We'll evaluate these (and make sure our governance tool knows about them as well). Since we're not putting JSON on an RPC path right now, it might be at an acceptable level of risk... we'll have to think about that. |
@zadjii-msft, you requested my review here but it already looks full of comments by @DHowett-MSFT and @adiviness that are probably sufficient so I'll move onto another one for now. Ping me if you really want me to look at this. |
static constexpr std::wstring_view SCHEMES_KEY{ L"schemes" }; | ||
static constexpr std::string_view PROFILES_KEY{ "profiles" }; | ||
static constexpr std::string_view KEYBINDINGS_KEY{ "keybindings" }; | ||
static constexpr std::string_view GLOBALS_KEY{ "globals" }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is globals the right name for this? It's like application settings... but also, i dunno, why aren't they at root level?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
frankly I just wanted to bundle them up. now that we lose the ordering we had before, the file would contain something like
{
"global1": val,
"global2": val,
"profiles": [
{ ... },
{ ... },
],
"global3": val,
"colorSchemes": [
{ ... }
],
"global4": val,
}
with the globals intermixed with things like the profiles, color schemes, etc, which I thought was annoying. I can switch it back if we want.
# Conflicts: # src/cascadia/TerminalApp/Profile.cpp
# Conflicts: # src/cascadia/TerminalApp/Profile.cpp
and the remaining PR nits
@DHowett-MSFT @miniksa can I get a second on this? |
Arg I thought I seconded. Sorry! |
return { FileIO::ReadTextAsync(storageFile, UnicodeEncoding::Utf8).get() }; | ||
auto buffer = FileIO::ReadBufferAsync(storageFile).get(); | ||
auto bufferData = buffer.data(); | ||
std::vector<uint8_t> bytes{ bufferData, bufferData + buffer.Length() }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, do we need to make a copy into a vector and THEN a copy into a string?
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Summary of the Pull Request
Switch to using jsoncpp as our json library. This lets us pretty-print the json file by default, and lets users place comments in the json file.
PR Checklist
this would really be a good opportunity to add some testsYea this is gonna be a follow-up, see Refactor pure C++ types from TerminalApp.dll into a lib #1042Detailed Description of the Pull Request / Additional comments
We will now only re-write the file when the actual logical structure of the json object changes, not only when the serialization changes.
Unfortunately, this will remove any existing ordering of profiles, and make the order random. We don't terribly care though, because when #754 lands, this will be less painful.
It also introduces a top-level
globals
object to hold all the global properties, includingkeybindings
. Existing profiles should gracefully upgrade.