Skip to content

Commit

Permalink
Fix swapped rect properties
Browse files Browse the repository at this point in the history
Fixed a logical bug in MaskConfig swapped some screen and document.body properties.

- document.body.clientTop <--> document.body.clientWidth
- screen.availTop <--> screen.availLeft
- screen.availWidth <--> screen.availHeight
  • Loading branch information
daijro committed Sep 30, 2024
1 parent 8a9b062 commit 7598704
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions additions/camoucfg/MaskConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ inline std::optional<bool> GetBool(const std::string& key) {
}

inline std::optional<std::array<uint32_t, 4>> GetRect(
const std::string& top, const std::string& left, const std::string& height,
const std::string& width) {
const std::string& left, const std::string& top, const std::string& width,
const std::string& height) {
// Make top and left default to 0
std::array<std::optional<uint32_t>, 4> values = {
GetUint32(top).value_or(0), GetUint32(left).value_or(0),
GetUint32(height), GetUint32(width)};
GetUint32(left).value_or(0), GetUint32(top).value_or(0),
GetUint32(width), GetUint32(height)};

// If height or width is std::nullopt, return std::nullopt
if (!values[2].has_value() || !values[3].has_value()) {
Expand All @@ -185,10 +185,10 @@ inline std::optional<std::array<uint32_t, 4>> GetRect(
}

inline std::optional<std::array<int32_t, 4>> GetInt32Rect(
const std::string& top, const std::string& left, const std::string& height,
const std::string& width) {
const std::string& left, const std::string& top, const std::string& width,
const std::string& height) {
// Calls GetRect but casts to int32_t
if (auto optValue = GetRect(top, left, height, width)) {
if (auto optValue = GetRect(left, top, width, height)) {
std::array<int32_t, 4> result;
std::transform(optValue->begin(), optValue->end(), result.begin(),
[](const auto& val) { return static_cast<int32_t>(val); });
Expand Down
6 changes: 3 additions & 3 deletions patches/fingerprint-injection.patch
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ index 807cb4ec25..3df0e0f70f 100644

+ if (doc->GetBodyElement() == this) {
+ if (auto conf = MaskConfig::GetInt32Rect(
+ "document.body.clientTop", "document.body.clientLeft",
+ "document.body.clientLeft", "document.body.clientTop",
+ "document.body.clientWidth", "document.body.clientHeight")) {
+ if (conf.has_value()) {
+ auto values = conf.value();
Expand Down Expand Up @@ -394,8 +394,8 @@ index 4bd1e0c964..a5a95d3fdf 100644
}

CSSIntRect nsScreen::GetAvailRect() {
+ auto rect = MaskConfig::GetRect("screen.availTop", "screen.availLeft",
+ "screen.availHeight", "screen.availWidth");
+ auto rect = MaskConfig::GetRect("screen.availLeft", "screen.availTop",
+ "screen.availWidth", "screen.availHeight");
+ if (rect.has_value()) {
+ auto values = rect.value();
+ return {values[0], values[1], values[2], values[3]};
Expand Down

0 comments on commit 7598704

Please sign in to comment.