oppia-android icon indicating copy to clipboard operation
oppia-android copied to clipboard

[Validation Issue]: Profile name accepts invalid inputs like single dot (.) or single space ( )

Open reshmimahadevan opened this issue 3 months ago • 18 comments

Describe the bug

The profile name field incorrectly allows a single dot (.) or a single space ( ). These are not valid names. Double dots (..) and double spaces ( ) are rejected correctly.

Steps To Reproduce

  • After App starts up
  • Go to Admin Control and enter the Admin pin
  • Select Edit Profiles
  • Click and Rename any profile(New/Admin) with single dot (.) or a single space ( )

Expected Behavior

  • Profile names should require at least one valid letter
  • Inputs that are only special characters or spaces should not be accepted

Screenshots/Videos

https://github.com/user-attachments/assets/a6f34375-6427-4ccf-b302-42d98c59b637

Image

What device/emulator are you using?

Vivo v21e

Which Android version is your device/emulator running?

Android 13

Which version of the Oppia Android app are you using?

0.16-beta-5f3e75afa7

Additional Context

No response

reshmimahadevan avatar Sep 24 '25 00:09 reshmimahadevan

From a quick glance at https://github.com/oppia/oppia-android/blob/develop/utility/src/main/java/org/oppia/android/util/profile/ProfileNameValidator.kt this appears to be an existing issue with the validator, and one that we perhaps missed in the original implementation. We should probably prohibit symbols starting names and instead require letters only.

BenHenning avatar Sep 29 '25 01:09 BenHenning

Hey, @reshmimahadevan if the issue is still open, I would like to take this up

satnam-singh-JustCode avatar Sep 30 '25 11:09 satnam-singh-JustCode

Hi @satnam-singh-JustCode, I would be happy to assign this to you. Have you began your repo set up?

adhiamboperes avatar Sep 30 '25 13:09 adhiamboperes

Hi @satnam-singh-JustCode, I would be happy to assign this to you. Have you began your repo set up?

yup

satnam-singh-JustCode avatar Oct 01 '25 07:10 satnam-singh-JustCode

Hi @satnam-singh-JustCode, how is it going with this issue?

adhiamboperes avatar Oct 07 '25 22:10 adhiamboperes

If the person is not active I can try to solve the issue. You can assign it to me.

vivekkumar04-max avatar Oct 08 '25 16:10 vivekkumar04-max

Planning to get into contributing to Oppia with this issue, seems simple enough and think can be fixed pretty easily. I have already setup the project and managed to recreate the issue. If no one else is currently working on this i will proceed with it? @adhiamboperes

ShankhanilSaha avatar Oct 08 '25 18:10 ShankhanilSaha

Hi @satnam-singh-JustCode , are you still working on this issue?

ShankhanilSaha avatar Oct 16 '25 04:10 ShankhanilSaha

Unasssigning @satnam-singh-JustCode due to inactivity. Please feel free to work on this @ShankhanilSaha

adhiamboperes avatar Oct 29 '25 15:10 adhiamboperes

@adhiamboperes I have fixed the issue by adding another function notOnlySymbols(name) in the isNameValid(name), function in utility/src/main/java/org/oppia/android/util/profile/ProfileNameValidator.kt this checks the name and verifies whether the name is of only symbols. When running the command java -jar ../oppia-android-tools/ktlint -F --android domain/src/**/*.kt utility/src/**/*.kt data/src/**/*.kt app/src/**/*.kt testing/src/**/*.kt scripts/src/**/*.kt instrumentation/src/**/*.kt for format checks i get and error saying word limit of line exceeded.

/home/shankhanil/opensource/oppia-android/utility/src/main/java/org/oppia/android/util/profile/ProfileNameValidator.kt:21:1: Exceeded max line length (100) (cannot be auto-corrected)

is there anyways this check excludes this particular line on this file? or i should find another way to fix this.

ShankhanilSaha avatar Oct 30 '25 07:10 ShankhanilSaha

Also shall I add validation that the name does not start with a symbol?

ShankhanilSaha avatar Oct 30 '25 07:10 ShankhanilSaha

@ShankhanilSaha, is it possible to check that the name doesn’t contain any symbols, i.e. letters and spaces only? Then we only need one function

adhiamboperes avatar Oct 30 '25 11:10 adhiamboperes

@adhiamboperes , yeah it sure is, but some special symbols like hyphens and dots are included in the special symbol list which ig should be allowed.

ShankhanilSaha avatar Oct 30 '25 12:10 ShankhanilSaha

I was thinking we could maybe change the function for checking repeated smbols to something along checkSymbolsFormatting(name) ehich checks bost repeated symbols and wheather it is a symbol only name.

ShankhanilSaha avatar Oct 30 '25 12:10 ShankhanilSaha

From a quick glance at https://github.com/oppia/oppia-android/blob/develop/utility/src/main/java/org/oppia/android/util/profile/ProfileNameValidator.kt this appears to be an existing issue with the validator, and one that we perhaps missed in the original implementation. We should probably prohibit symbols starting names and instead require letters only.

@ShankhanilSaha, please see the quoted comment posted by @BenHenning above. Instead of adding any new functions, we instead want to make the naming standard stricter, by prohibiting any symbols in fun isNameValid. We should also trim the profile name before validation, which will remove extra spaces and ensure a blank space cannot be accepted as a name.

adhiamboperes avatar Nov 01 '25 10:11 adhiamboperes

@adhiamboperes , okay then. I will try making a isNameValid() function with stricter rules.

ShankhanilSaha avatar Nov 01 '25 11:11 ShankhanilSaha

@adhiamboperes please review the implementation method of the PR.

ShankhanilSaha avatar Nov 03 '25 14:11 ShankhanilSaha

Hi everyone 👋,

I’ve reviewed ProfileNameValidator.kt and the discussion around this PR. Initially, I considered using a regex-based approach, but after understanding that Oppia supports multilingual input, I think it’s better to keep the Unicode-safe validation logic. To make the validation simpler and stricter, we could add a concise pre-check to ensure the name isn’t blank, has a meaningful length, and includes at least one alphabetic character using Oppia’s existing isAlphabetic() helper:

""" val trimmed = name.trim() if (!trimmed.isNotBlank() || trimmed.length < 2 || !trimmed.any { it.isAlphabetic() }) return false """

This would reject names made only of spaces or symbols (like "." or " ") while preserving valid names such as "Anne-Marie" or "O’Connor". Just sharing this as an idea that might help make the validator simpler and more consistent — and if the current PR needs further updates or becomes inactive, I’d be glad to help implement it. 🙂

thevedantchourey avatar Nov 11 '25 15:11 thevedantchourey

@ShankhanilSaha Is you are still working on this issue?

itsadityaaaaa avatar Dec 13 '25 13:12 itsadityaaaaa

@itsadityaaaaa yes i am.

ShankhanilSaha avatar Dec 13 '25 13:12 ShankhanilSaha