Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore case in validatePackageName #1660

Merged
merged 2 commits into from
Jul 28, 2022
Merged

Conversation

mlazari
Copy link
Contributor

@mlazari mlazari commented Jul 28, 2022

Summary:

Currently validatePackageName fails for package names containing uppercase letters. A message like this is shown during pod install:

warn Invalid application's package name "com.lugg.ReactNativeConfig" in 'AndroidManifest.xml'. Read guidelines for setting the package name here: https://developer.android.com/studio/build/application-id
warn Invalid application's package name "com.BV.LinearGradient" in 'AndroidManifest.xml'. Read guidelines for setting the package name here: https://developer.android.com/studio/build/application-id
warn Invalid application's package name "com.lugg.ReactNativeConfig" in 'AndroidManifest.xml'. Read guidelines for setting the package name here: https://developer.android.com/studio/build/application-id
warn Invalid application's package name "com.BV.LinearGradient" in 'AndroidManifest.xml'. Read guidelines for setting the package name here: https://developer.android.com/studio/build/application-id

However both the package name (https://developer.android.com/guide/topics/manifest/manifest-element.html#package) and the application id (https://developer.android.com/studio/build/application-id) are allowed to contain upper case letters.

Screenshot 2022-07-28 at 14 29 33
Screenshot 2022-07-28 at 14 29 58

This change adds the "i" flag to the regex to ignore case when validating package name.

Related issue: facebook/react-native#34247

Test Plan:

I verified in browser console that the updated regex works correctly:
Screenshot 2022-07-28 at 15 05 24

Currently `validatePackageName` fails for package names containing uppercase letters. A message like this is shown during pod install:
```
warn Invalid application's package name "com.lugg.ReactNativeConfig" in 'AndroidManifest.xml'. Read guidelines for setting the package name here: https://developer.android.com/studio/build/application-id
warn Invalid application's package name "com.BV.LinearGradient" in 'AndroidManifest.xml'. Read guidelines for setting the package name here: https://developer.android.com/studio/build/application-id
warn Invalid application's package name "com.lugg.ReactNativeConfig" in 'AndroidManifest.xml'. Read guidelines for setting the package name here: https://developer.android.com/studio/build/application-id
warn Invalid application's package name "com.BV.LinearGradient" in 'AndroidManifest.xml'. Read guidelines for setting the package name here: https://developer.android.com/studio/build/application-id
```
 However both the package name (https://developer.android.com/guide/topics/manifest/manifest-element.html#package) and the application id (https://developer.android.com/studio/build/application-id) are allowed to contain upper case letters.

This change adds the "i" flag to the regex to ignore case when validating package name.

Related issue: facebook/react-native#34247
@matinzd
Copy link

matinzd commented Jul 28, 2022

Do you think this is gonna fix pod install properly? Because I think this function should not get called when running pod install at all.

@mlazari
Copy link
Contributor Author

mlazari commented Jul 28, 2022

@matinzd It will not fix pod install calling android specific configuration. I am not familiar enough with the code in this repo to know how to do that. It fixes only it considering valid package names as invalid.

Copy link

@matinzd matinzd left a comment

Choose a reason for hiding this comment

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

Looks good to me, but the problem I have with this is why getAndroidProject should be called via pod install?
I think this needs to be fixed in cli bin with passing params. If it's gradle running the script, android should be checked and if this is being called from native_modules in the ruby script, only ios should only be called.

@thymikee
Copy link
Member

Thanks! Looks good. Can you please add a test with this case?

@thymikee
Copy link
Member

@matinzd right, we could add a --platform flag to the config command that would filter explored platforms

@mlazari
Copy link
Contributor Author

mlazari commented Jul 28, 2022

@thymikee Added a few tests for validatePackageName.

@thymikee thymikee merged commit 2a314d3 into react-native-community:main Jul 28, 2022
thymikee pushed a commit that referenced this pull request Jul 28, 2022
* Ignore case in validatePackageName

Currently `validatePackageName` fails for package names containing uppercase letters. A message like this is shown during pod install:
```
warn Invalid application's package name "com.lugg.ReactNativeConfig" in 'AndroidManifest.xml'. Read guidelines for setting the package name here: https://developer.android.com/studio/build/application-id
warn Invalid application's package name "com.BV.LinearGradient" in 'AndroidManifest.xml'. Read guidelines for setting the package name here: https://developer.android.com/studio/build/application-id
warn Invalid application's package name "com.lugg.ReactNativeConfig" in 'AndroidManifest.xml'. Read guidelines for setting the package name here: https://developer.android.com/studio/build/application-id
warn Invalid application's package name "com.BV.LinearGradient" in 'AndroidManifest.xml'. Read guidelines for setting the package name here: https://developer.android.com/studio/build/application-id
```
 However both the package name (https://developer.android.com/guide/topics/manifest/manifest-element.html#package) and the application id (https://developer.android.com/studio/build/application-id) are allowed to contain upper case letters.

This change adds the "i" flag to the regex to ignore case when validating package name.

Related issue: facebook/react-native#34247

* Add tests for validatePackageName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants