From f2ec459c3aeb4bab0f66c8d6a4e00c2d293bc4ec Mon Sep 17 00:00:00 2001 From: Alex Fishman Date: Fri, 4 Sep 2026 17:46:20 -0700 Subject: [PATCH 1/2] docs(ios): fix Swift network-privacy regex leaving leading & in place MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Swift sample's regex was "&access_token=[0-9a-z\-]*" — an extra leading & that requires a preceding query parameter to match. When access_token is the first parameter in the URL (e.g. ?access_token=SECRET), the Swift version silently leaves it in the recorded network event, while the equivalent Objective-C sample (without the leading &) correctly strips it either way. This is sample code for a privacy/PII-redaction feature, so the bug directly undermines what the page is teaching. Dropped the leading & to match the Objective-C sample. Co-Authored-By: Claude Sonnet 5 --- docs/sdk/ios/privacy/network.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sdk/ios/privacy/network.mdx b/docs/sdk/ios/privacy/network.mdx index b6b3551..07c1fb9 100644 --- a/docs/sdk/ios/privacy/network.mdx +++ b/docs/sdk/ios/privacy/network.mdx @@ -78,7 +78,7 @@ Your class should implement the **BugseeDelegate** protocol and it must set itse func bugseeFilterNetworkEvent(_ event: BugseeNetworkEvent, completionHandler decisionBlock: @escaping BugseeNetworkFilterDecisionBlock) { let regex : NSRegularExpression do { - regex = try NSRegularExpression.init(pattern: "&access_token=[0-9a-z\\-]*", options: NSRegularExpression.Options.caseInsensitive) + regex = try NSRegularExpression.init(pattern: "access_token=[0-9a-z\\-]*", options: NSRegularExpression.Options.caseInsensitive) let range = NSMakeRange(0 , (event.url!.count)) if (event.url != nil) { event.url = regex.stringByReplacingMatches(in: event.url!, options: .reportProgress, range: range, withTemplate: "") From a57a06cae38a4a724c08d194dc451f332b86b116 Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Sat, 5 Sep 2026 10:54:22 +0500 Subject: [PATCH 2/2] docs(ios): guard event.url before unwrapping it in the Swift sample MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sample force-unwrapped event.url to build the NSRange on the line *above* the `if (event.url != nil)` guard, so the guard never protected anything — a nil URL crashes the delegate. Rewrite as `if let url = event.url`, which covers both uses, and size the NSRange with url.utf16.count rather than url.count: NSRange indexes UTF-16 code units (matching the Objective-C sample's -length), so a URL with non-ASCII characters was under-covered and could skip matches. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Change-Id: I81be03aad11d0e3c370ebf1cf0f976f250338c93 --- docs/sdk/ios/privacy/network.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/sdk/ios/privacy/network.mdx b/docs/sdk/ios/privacy/network.mdx index 07c1fb9..9d920c0 100644 --- a/docs/sdk/ios/privacy/network.mdx +++ b/docs/sdk/ios/privacy/network.mdx @@ -79,9 +79,9 @@ func bugseeFilterNetworkEvent(_ event: BugseeNetworkEvent, completionHandler dec let regex : NSRegularExpression do { regex = try NSRegularExpression.init(pattern: "access_token=[0-9a-z\\-]*", options: NSRegularExpression.Options.caseInsensitive) - let range = NSMakeRange(0 , (event.url!.count)) - if (event.url != nil) { - event.url = regex.stringByReplacingMatches(in: event.url!, options: .reportProgress, range: range, withTemplate: "") + if let url = event.url { + let range = NSMakeRange(0, url.utf16.count) + event.url = regex.stringByReplacingMatches(in: url, options: .reportProgress, range: range, withTemplate: "") } }catch { print("Somethings went wrong!") }