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

plugins/bf4: fix JSON encoding. #2275

Merged
merged 1 commit into from May 18, 2016

Conversation

@mkrautz
Copy link
Member

commented May 16, 2016

The previous code accidently used the
C-string "host" and "serverID" variables
in the JSON output for the context and
identity.

To avoid too many changes, this commit
changes the JSON escape function to
work on C strings instead, and uses
that to escape the "host" and "serverID"
strings from the game before emitting
them into the JSON documents.

This commit also adds some extra code
to ensure that the game strings we
include in the JSON document are
within the printable ASCII range.

@mkrautz

This comment has been minimized.

Copy link
Member Author

commented May 16, 2016

Note: not build tested.

@mkrautz

This comment has been minimized.

Copy link
Member Author

commented May 16, 2016

Host = jsonStringEscape(Host);
if (Host.find("bot") == std::string::npos) // Set host string as empty if "bot" is found in it.
escape(host);
if (strstr(host, "bot") == NULL) // Set host string as empty if "bot" is found in it.

This comment has been minimized.

Copy link
@mkrautz

mkrautz May 16, 2016

Author Member

This comment isn't correct. It wasn't before either.

What's the idea, @davidebeatrici?

This comment has been minimized.

Copy link
@mkrautz

mkrautz May 16, 2016

Author Member

Talked to @davidebeatrici on IRC -- the intention is what the code does: if "host" contains "bot", the JSON should not contain a Host.

Host = jsonStringEscape(Host);
if (Host.find("bot") == std::string::npos) // Set host string as empty if "bot" is found in it.
escape(host);
if (strstr(host, "bot") == NULL) // Set host string as empty if "bot" is found in it.
if (!Host.empty()) {

This comment has been minimized.

Copy link
@mkrautz

mkrautz May 16, 2016

Author Member

Host doesn't exist anymore.

std::ostringstream ocontext;
ocontext << " {\"Server ID\": \"" << ServerID << "\"}"; // Set context with server ID
ocontext << " {\"Server ID\": \"" << serverID << "\"}"; // Set context with server ID

This comment has been minimized.

Copy link
@davidebeatrici

davidebeatrici May 18, 2016

Member

This needs to be changed in "serverid".

@davidebeatrici

This comment has been minimized.

Copy link
Member

commented May 18, 2016

The plugin is working flawlessly.
I changed host and team system: https://www.diffchecker.com/af9ixyoq

plugins/bf4: fix JSON encoding.
The previous code accidently used the
C-string "host" and "serverID" variables
in the JSON output for the context and
identity.

To avoid too many changes, this commit
changes the JSON escape function to
work on C strings instead, and uses
that to escape the "host" and "serverID"
strings from the game before emitting
them into the JSON documents.

This commit also adds some extra code
to ensure that the game strings we
include in the JSON document are
within the printable ASCII range.

@mkrautz mkrautz force-pushed the mkrautz:bf4-json-fix branch from d284f1e to 0c07d25 May 18, 2016

@mkrautz mkrautz merged commit 0c07d25 into mumble-voip:master May 18, 2016

mkrautz added a commit that referenced this pull request May 18, 2016
@mkrautz

This comment has been minimized.

Copy link
Member Author

commented May 18, 2016

Landed via bed423e.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.