Skip to content
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

The jsonparser doesn't work with escaped unicode characters #2495

Closed
Tracked by #2271
zjeffer opened this issue Sep 10, 2023 · 2 comments · Fixed by #2496
Closed
Tracked by #2271

The jsonparser doesn't work with escaped unicode characters #2495

zjeffer opened this issue Sep 10, 2023 · 2 comments · Fixed by #2496

Comments

@zjeffer
Copy link
Contributor

zjeffer commented Sep 10, 2023

I wrote a test for this:

TEST_CASE("Json with unicode", "[json]") {
  SECTION("Parse json with unicode") {
	std::string stringToTest = R"({"test": "\xab"})";
	waybar::util::JsonParser parser;
	Json::Value jsonValue = parser.parse(stringToTest);
	REQUIRE(jsonValue["test"].asString() == "\xab");
  }
}
../test/JsonParser.cpp:20: FAILED:
due to unexpected exception with message:
  * Line 1, Column 10
    Bad escape sequence in string
  See Line 1, Column 13 for detail.

causes problems with hyprland IPC if for example the monitor description/model contains unicode characters: #2475

I'm not sure if this is a problem with our parsing code (include/util/json.hpp), or a problem with the upstream jsoncpp library we're using?

@amplexus
Copy link

I have a monitor with hex values in the name as output by hyprctl monitors and am getting errors with waybar hyprland workspaces that looks kind of like #2475 but also kind of like #2398:

# hyprctl monitors
Monitor eDP-1 (ID 0):
	[email protected] at 0x0
	description: BOE 0x0866 (eDP-1)
	make: BOE
	model: 0x0866
	serial: 
	active workspace: 3 (3)
	reserved: 0 30 0 0
	scale: 2.00
	transform: 0
	focused: yes
	dpmsStatus: 1
	vrr: 0

I'm wondering whether the parser also is unhappy when it sees 0xXXXX characters in the input string (monitor metadata)?

@amplexus
Copy link

Ok never mind. I added a test to https://github.com/open-source-parsers/jsoncpp containing my monitor description string and it didn't complain. My issue is unrelated to this bug.

zjeffer added a commit to zjeffer/Waybar that referenced this issue Jan 14, 2024
* replace \x with \u00 to follow JSON spec
* fixes Alexays#2475 and Alexays#2495
* added unit tests for json parsing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants