[PR #721] [MERGED] Fix false positive in ContainsAll function #1390

Closed
opened 2026-05-07 01:01:53 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/binwiederhier/ntfy/pull/721
Author: @adamantike
Created: 5/12/2023
Status: Merged
Merged: 5/12/2023
Merged by: @binwiederhier

Base: mainHead: fix/containsAll-false-positive


📝 Commits (1)

  • ebd4367 Fix false positive in ContainsAll function

📊 Changes

2 files changed (+13 additions, -9 deletions)

View changed files

📝 util/util.go (+6 -8)
📝 util/util_test.go (+7 -1)

📄 Description

As the ContainsAll is working with a match counter, it could return a false positive when the haystack slice contains duplicate elements.

This can be checked with the included testing scenario, with haystack = [1, 1] and needles = [1, 2]. Iterating over the haystack to check for items to be present in needles will increase the match counter to 2, even if 2 is not present in the first slice.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/binwiederhier/ntfy/pull/721 **Author:** [@adamantike](https://github.com/adamantike) **Created:** 5/12/2023 **Status:** ✅ Merged **Merged:** 5/12/2023 **Merged by:** [@binwiederhier](https://github.com/binwiederhier) **Base:** `main` ← **Head:** `fix/containsAll-false-positive` --- ### 📝 Commits (1) - [`ebd4367`](https://github.com/binwiederhier/ntfy/commit/ebd4367dda4f9a77b58518798913bf7635bddb20) Fix false positive in ContainsAll function ### 📊 Changes **2 files changed** (+13 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `util/util.go` (+6 -8) 📝 `util/util_test.go` (+7 -1) </details> ### 📄 Description As the `ContainsAll` is working with a match counter, it could return a false positive when the `haystack` slice contains duplicate elements. This can be checked with the included testing scenario, with `haystack = [1, 1]` and `needles = [1, 2]`. Iterating over the haystack to check for items to be present in needles will increase the match counter to 2, even if `2` is not present in the first slice. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-07 01:01:53 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#1390
No description provided.