-
-
Notifications
You must be signed in to change notification settings - Fork 11
fix: Sanitize Variant values on Android #397
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0461c89
Sanitize Variant values on Android
limbonaut 650f876
Add "Test diverse context" tool in project
limbonaut 7738eb6
Update CHANGELOG.md
limbonaut d9dfdcb
Update CHANGELOG.md
limbonaut d6834ab
Merge branch 'main' into fix/android-variant-conv
limbonaut 7959ccb
Fix depth bump
limbonaut 421b73f
Handle non-string keys
limbonaut 09e57d3
Capitalize and whitespace
limbonaut 685c35e
Dont stringify nulls
limbonaut 861e2a4
Fix namespace closing comment style
limbonaut File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#include "android_util.h" | ||
|
||
#include "sentry/common_defs.h" | ||
|
||
using namespace godot; | ||
|
||
namespace sentry::android { | ||
|
||
Variant sanitize_variant(const Variant &p_value, int p_depth) { | ||
switch (p_value.get_type()) { | ||
case Variant::DICTIONARY: { | ||
if (p_depth > VARIANT_CONVERSION_MAX_DEPTH) { | ||
ERR_PRINT_ONCE("Sentry: Maximum Variant depth reached!"); | ||
return Variant(); | ||
} | ||
|
||
Dictionary old_dict = p_value; | ||
Dictionary new_dict; | ||
|
||
const Array &keys = old_dict.keys(); | ||
for (int i = 0; i < keys.size(); i++) { | ||
const Variant &key = keys[i]; | ||
new_dict[key.stringify()] = sanitize_variant(old_dict[key], p_depth + 1); | ||
} | ||
|
||
return new_dict; | ||
} break; | ||
case Variant::ARRAY: | ||
case Variant::PACKED_BYTE_ARRAY: | ||
case Variant::PACKED_INT32_ARRAY: | ||
case Variant::PACKED_INT64_ARRAY: | ||
case Variant::PACKED_FLOAT32_ARRAY: | ||
case Variant::PACKED_FLOAT64_ARRAY: | ||
case Variant::PACKED_STRING_ARRAY: | ||
case Variant::PACKED_VECTOR2_ARRAY: | ||
case Variant::PACKED_VECTOR3_ARRAY: | ||
case Variant::PACKED_COLOR_ARRAY: | ||
case Variant::PACKED_VECTOR4_ARRAY: { | ||
if (p_depth > VARIANT_CONVERSION_MAX_DEPTH) { | ||
ERR_PRINT_ONCE("Sentry: Maximum Variant depth reached!"); | ||
return Variant(); | ||
} | ||
|
||
Array arr; | ||
bool oob = false; | ||
bool valid = true; | ||
int i = 0; | ||
|
||
do { | ||
Variant item = p_value.get_indexed(i++, valid, oob); | ||
if (valid) { | ||
arr.append(sanitize_variant(item, p_depth + 1)); | ||
} | ||
} while (!oob); | ||
|
||
return arr; | ||
} break; | ||
case Variant::VECTOR2: | ||
case Variant::VECTOR2I: | ||
case Variant::RECT2: | ||
case Variant::RECT2I: | ||
case Variant::VECTOR3: | ||
case Variant::VECTOR3I: | ||
case Variant::TRANSFORM2D: | ||
case Variant::VECTOR4: | ||
case Variant::VECTOR4I: | ||
case Variant::PLANE: | ||
case Variant::QUATERNION: | ||
case Variant::AABB: | ||
case Variant::BASIS: | ||
case Variant::TRANSFORM3D: | ||
case Variant::PROJECTION: | ||
case Variant::COLOR: | ||
case Variant::STRING_NAME: | ||
case Variant::NODE_PATH: | ||
case Variant::RID: | ||
case Variant::OBJECT: | ||
case Variant::CALLABLE: | ||
case Variant::SIGNAL: { | ||
return p_value.stringify(); | ||
} break; | ||
default: { | ||
return p_value; | ||
} break; | ||
} | ||
} | ||
|
||
} //namespace sentry::android |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
|
||
#include <godot_cpp/variant/variant.hpp> | ||
|
||
namespace sentry::android { | ||
|
||
godot::Variant sanitize_variant(const godot::Variant &p_value, int p_depth = 0); | ||
|
||
} // namespace sentry::android |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.