Skip to content

Conversation

@JorgeMucientes
Copy link
Contributor

@JorgeMucientes JorgeMucientes commented Dec 23, 2022

Fixes: #8056

Description

Fixes crash when trying to log in using their site address if the site address contains suffixes like wp-admin or wp-login.php

Testing instructions

Log into the app using site address with wp-admin suffix and check that the app doesn't crash.

Images/gif

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@JorgeMucientes JorgeMucientes added type: bug A confirmed bug. status: do not merge Dependent on another PR, ready for review but not ready for merge. labels Dec 23, 2022
@JorgeMucientes JorgeMucientes marked this pull request as ready for review December 23, 2022 16:12
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 23, 2022

You can test the changes on this Pull Request by downloading an installable build, or scanning this QR code:

@JorgeMucientes JorgeMucientes marked this pull request as draft December 26, 2022 16:07
@JorgeMucientes JorgeMucientes removed their assignment Dec 26, 2022
@codecov-commenter
Copy link

codecov-commenter commented Dec 26, 2022

Codecov Report

Base: 43.02% // Head: 43.02% // Decreases project coverage by -0.00% ⚠️

Coverage data is based on head (9c519dc) compared to base (2f9b61b).
Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##              trunk    #8083      +/-   ##
============================================
- Coverage     43.02%   43.02%   -0.01%     
  Complexity     3522     3522              
============================================
  Files           679      679              
  Lines         36956    36958       +2     
  Branches       4790     4790              
============================================
  Hits          15901    15901              
- Misses        19629    19631       +2     
  Partials       1426     1426              
Impacted Files Coverage Δ
.../sitediscovery/SitePickerSiteDiscoveryViewModel.kt 0.00% <0.00%> (ø)
...in/kotlin/com/woocommerce/android/util/UrlUtils.kt 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@JorgeMucientes JorgeMucientes changed the title Update login library version with fix Fix crash when logging in with site address Dec 26, 2022
@JorgeMucientes JorgeMucientes marked this pull request as ready for review December 26, 2022 17:11
@JorgeMucientes JorgeMucientes removed the status: do not merge Dependent on another PR, ready for review but not ready for merge. label Dec 26, 2022
@JorgeMucientes JorgeMucientes added this to the 11.8 milestone Dec 26, 2022
* Basic sanitization of the URL based on the same logic we use in the XMLRPC discovery
* see: https://github.com/wordpress-mobile/WordPress-FluxC-Android/blob/94601a5d4c1c98068adde0352ecc25e6d0046f35/fluxc/src/main/java/org/wordpress/android/fluxc/network/discovery/SelfHostedEndpointFinder.java#L292
*/
fun String.sanitiseUrl(): String {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a np, this extension will be suggested in the autocomplete for all of the String instances, this is not a blocker, but without context, it's not clear what it does. Before, it was a private extension inside the class SitePickerSiteDiscoveryViewModel, so it was clear what it was about.
WDYT about moving it inside UrlUtils? we can then keep it as an extension and call it by providing the context receiver: with(urlUtils) { url.sanitiseUrl() }, or make it a regular function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point @hichamboushaba . I've moved it inside UrlUtils to make it clear “sanitizing” should only be applied to URLs.

Copy link
Member

@hichamboushaba hichamboushaba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well, thanks for taking care of this @JorgeMucientes 👍.

I left a comment above, but it's not a blocker, feel free to merge if you want 🙂.

Copy link
Member

@hichamboushaba hichamboushaba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the changes @JorgeMucientes 💯

@hichamboushaba hichamboushaba merged commit a06bbd1 into trunk Dec 28, 2022
@hichamboushaba hichamboushaba deleted the fix/8056-crash-on-log-in branch December 28, 2022 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug A confirmed bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash when login in with site address

5 participants