Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix(input): by default, do not trim input[type=password] values #8250

Closed
wants to merge 1 commit into from

Conversation

caitp
Copy link
Contributor

@caitp caitp commented Jul 18, 2014

Previously, all input types using ngModel and textInputType() would trim values if the ng-trim attribute was unspecified. This is undesirable for passwords because a user's input should always be canonical in that case.

This CL changes this behaviour by only trimming by-default if the input type is not password. In the future, if other input types need to be checked, or if the input type needs to be checked at runtime, this may be refactored to support those cases.

BREAKING CHANGE:

Previously, input[type=password] would trim values by default. This is no longer the case, and requires an explicit ng-trim="value other than 'false'" to ensure that the value is trimmed in casees where this is actually desirable.

Example:

<!-- WILL NOT TRIM VALUE -->
<input type="password" ng-model="password">
<input type="password" ng-model="password" ng-trim="false">

<!-- WILL TRIM VALUE -->
<input type="password" ng-model="password" ng-trim="ANYTHING ELSE"> 

Closes #8230

@mary-poppins
Copy link

Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.

  • Uses the issue template (#8250)

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

@caitp caitp added cla: yes and removed cla: no labels Jul 18, 2014
@Narretz
Copy link
Contributor

Narretz commented Jul 18, 2014

I don't really understand why we need this change. Are there password with leading / trailing whitespace?

@Narretz Narretz added this to the Backlog milestone Jul 18, 2014
@caitp
Copy link
Contributor Author

caitp commented Jul 18, 2014

good question, but who cares!

@IgorMinar
Copy link
Contributor

oops.. we never thought about trimming and passwords. this is definitely a fix that should be backported to 1.2.

But does it make sense for passwords to ever be auto trimmed? in which case do we even need to support enabling the trimming? It looks like dead code to me. I suggest removing it and just documenting that trimming is not supported for input[type=password].

@caitp
Copy link
Contributor Author

caitp commented Aug 1, 2014

sounds good to me

Do not trim input[type=password] values

BREAKING CHANGE:

Previously, input[type=password] would trim values by default, and would require an explicit ng-trim="false"
to disable the trimming behaviour. After this CL, ng-trim no longer effects input[type=password], and will
never trim the password value.
@caitp
Copy link
Contributor Author

caitp commented Aug 1, 2014

Changed to never trim if the input type is 'password'

@caitp
Copy link
Contributor Author

caitp commented Aug 11, 2014

PTAL --- are we good to check this in for beta 18?

@btford btford removed the gh: PR label Aug 20, 2014
@IgorMinar IgorMinar modified the milestones: Backlog, 1.3.0-beta.19 Aug 21, 2014
@caitp caitp closed this in a7fb357 Aug 21, 2014
caitp added a commit that referenced this pull request Aug 21, 2014
Do not trim input[type=password] values

BREAKING CHANGE:

Previously, input[type=password] would trim values by default, and would require an explicit ng-trim="false"
to disable the trimming behaviour. After this CL, ng-trim no longer effects input[type=password], and will
never trim the password value.

Closes #8250
Closes #8230

Conflicts:
	src/ng/directive/input.js
@eekboom
Copy link

eekboom commented Aug 25, 2014

Unfortunately this is yet another change, that causes me additional work instead of simplifying things.

I understand the rationale to not trim password fields by default.
But who are you to decide that no user of angular would ever want to have password fields trimmed?
We have an explicit requirement from our users to do so to avoid locked out users that have accidentally added a space to their passwords.

I think angular js itself should also be driven by actual user requirements.
Or maybe I missed a discussion somewhere?

Another argument is the "principle of least surprise": If I add ng-trim="true" to a password field, it should not be silently ignored.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

password input fields inconsistant with angular values
6 participants