[PR #5118] [MERGED] [PM-14846] Improve IP Address and Port Handling in StringExtensions #5496

Closed
opened 2025-11-27 00:06:20 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/5118
Author: @SaintPatrck
Created: 5/1/2025
Status: Merged
Merged: 5/1/2025
Merged by: @SaintPatrck

Base: mainHead: PM-14846/improve-ip-address-handling-for-autofill


📝 Commits (1)

  • ffcae91 [PM-14846] Improve IP Address and Port Handling in StringExtensions

📊 Changes

2 files changed (+101 additions, -2 deletions)

View changed files

📝 app/src/main/java/com/x8bit/bitwarden/data/platform/util/StringExtensions.kt (+50 -2)
📝 app/src/test/java/com/x8bit/bitwarden/data/util/StringExtensionsTest.kt (+51 -0)

📄 Description

🎟️ Tracking

PM-14846
PM-20513
Relates to #5084

📔 Objective

Correct parsing of IP addresses with and without scheme and port. URI cannot parse an IP address with a port when it does not also include the scheme (http, https), so autofill matching triggered from the Quick Tile was not working properly.

  • New Function: Added isIpAddress() to check if a string is a valid IPv4 address, optionally with a port and scheme.
  • Regex Update: Added the IP_ADDRESS_WITH_OPTIONAL_PORT regex. It validates IPv4 addresses with or without ports (0-65535 range), with an optional http:// or https:// prefix.
  • URI Parsing: Modified toUriOrNull() to handle IP addresses without schemes by adding a default "https://" scheme before parsing.
  • Tests update: Added new tests for isIpAddress function.

📸 Screenshots

Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

🔄 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/bitwarden/android/pull/5118 **Author:** [@SaintPatrck](https://github.com/SaintPatrck) **Created:** 5/1/2025 **Status:** ✅ Merged **Merged:** 5/1/2025 **Merged by:** [@SaintPatrck](https://github.com/SaintPatrck) **Base:** `main` ← **Head:** `PM-14846/improve-ip-address-handling-for-autofill` --- ### 📝 Commits (1) - [`ffcae91`](https://github.com/bitwarden/android/commit/ffcae9107734db06685fc54c868cf1e14431435b) [PM-14846] Improve IP Address and Port Handling in StringExtensions ### 📊 Changes **2 files changed** (+101 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `app/src/main/java/com/x8bit/bitwarden/data/platform/util/StringExtensions.kt` (+50 -2) 📝 `app/src/test/java/com/x8bit/bitwarden/data/util/StringExtensionsTest.kt` (+51 -0) </details> ### 📄 Description ## 🎟️ Tracking PM-14846 PM-20513 Relates to #5084 ## 📔 Objective Correct parsing of IP addresses with and without scheme and port. `URI` cannot parse an IP address with a port when it does not also include the scheme (http, https), so autofill matching triggered from the Quick Tile was not working properly. - **New Function:** Added `isIpAddress()` to check if a string is a valid IPv4 address, optionally with a port and scheme. - **Regex Update:** Added the `IP_ADDRESS_WITH_OPTIONAL_PORT` regex. It validates IPv4 addresses with or without ports (0-65535 range), with an optional `http://` or `https://` prefix. - **URI Parsing:** Modified `toUriOrNull()` to handle IP addresses without schemes by adding a default "https://" scheme before parsing. - **Tests update**: Added new tests for `isIpAddress` function. ## 📸 Screenshots <!-- Required for any UI changes; delete if not applicable. Use fixed width images for better display. --> ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## 🦮 Reviewer guidelines <!-- Suggested interactions but feel free to use (or not) as you desire! --> - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹ️ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠️ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or ♻️ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-27 00:06:20 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#5496