[FIXED] [#775] [3.2.0] PasswordMask HideAll issue

  1. #1

    [FIXED] [#775] [3.2.0] PasswordMask HideAll issue

    There is a problem with PasswordMask HideAll not capturing the password typed in.

    1. Enter "aaaa" and press the login button.
    2. Select the PasswordField again. This will highlight the old password. Just start typing "bbbb" and press the login button.
    3. Select the PasswordField again. This will highlight the old password. First press Backspace or Delete then type "cccc" and press the login button.


    Step 1 will show you what you type - aaaa
    Step 2 will show you what you type - abbb (The first character is not replaced).
    Step 3 will show you what you type - cccc

    There is current an override of PasswordMask to fix a javascript error with HideAll - Thread 56771
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html>
    <html>
    <script runat="server">
    
    </script>
    <head runat="server">
        <title></title>
        <style type="text/css">
        </style>
        <script type="text/javascript">
    
            //Thread 56771 - March 17, 2015 - PasswordMask issue
            // If we set the mode to HideAll a javascript error occurs when
            // typing the first character.
            Ext.net.PasswordMask.override({
                onKeyPress: function () {
                    var me = this,
                    oldValue = me.cmp.lastValue || "";
    
                    if (me.mode != "hideall") {
                        return;
                    }
    
                    setTimeout(function () {
                        var newValue = me.cmp.getValue();
                        if (newValue.length < oldValue.length) {
                            me.onDelete(me.getCaretRange(), oldValue.length - newValue.length);
                        } else {
                            me.maskChars(newValue);
                        }
                        me._maskAll();
                    }, 0);
                }
            })
        </script>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
    
        <ext:Panel runat="server" Title="Password Mask Issue" Margin="5" Height="200" Width="400" BodyPadding="10" UI="Danger">
            <Items>
                <ext:TextField ID="Password" runat="server" FieldLabel="Password" ClientIDMode="Static" SelectOnFocus="true">
                    <Plugins>
                        <ext:PasswordMask runat="server" Mode="HideAll" Pattern="z" AllowAnyChars="true" />
                    </Plugins>
                </ext:TextField>
            </Items>
            <Buttons>
                <ext:Button runat="server" Text="Login" Handler="Ext.Msg.alert('Password ...', App.Password.getPassword());" />
            </Buttons>
        </ext:Panel>
    </body>
    </html>
    Last edited by Daniil; Apr 03, 2015 at 8:05 AM. Reason: [FIXED] [3.2.0]
  2. #2
    Hi Chris,

    Thank you for the report!

    I've reproduced and will be looking at that tomorrow morning with a fresh head.
  3. #3
    That is reproducible with v2 and v3.

    Created an Issue:
    https://github.com/extnet/Ext.NET/issues/775

    Please try this fix for v2. Once you confirm that it works, I'll commit to SVN.
    Ext.net.PasswordMask.override({
        renderHiddenField: function () {
            var field = this.getCmp();
    
            if (field.ownerCt) {
                field.ownerCt.items.add(this.hiddenField);
            } else {
                this.hiddenField.render(field.el.parent());
            }
    
            field.inputEl.on("keydown", this.onKeyDown, this);
        },
    
        onKeyDown: function (e) {
            var me = this,
                oldValue = me.cmp.lastValue || "";
    
            if (me.mode != "hideall") {
                return;
            }
    
            setTimeout(function () {
                var newValue = me.cmp.getValue(),
                    key = e.getKey();
    
                if ((newValue.length < oldValue.length) && ((key === e.BACKSPACE) || (key === e.DELETE))) {
                    me.onDelete(me.getCaretRange(), oldValue.length - newValue.length);
                } else {
                    me.maskChars(newValue);
                }
    
                me._maskAll();
            }, 0);
        }
    });
  4. #4
    Passes all of my tests. Thanks for the update. It is always interesting finding bugs that have not been found before. I obviously didn't find this one for the past 8 months because I always type my password correctly or with the same first character even if it was incorrect I guess.

    Please close the thread.
  5. #5
    Thank you confirming. I've applied the fix in SVN.

    v2: revision 6411 (branches/2). It will go to 2.5.4.
    v3: revision 6412 (trunk). It will go to 3.2.0.

Similar Threads

  1. Replies: 3
    Last Post: Mar 17, 2015, 2:21 PM
  2. Plugin PasswordMask - not found,
    By asics167 in forum 2.x Help
    Replies: 2
    Last Post: Dec 12, 2013, 5:05 AM
  3. Plugin PasswordMask - not found?
    By asics167 in forum 2.x Help
    Replies: 1
    Last Post: Dec 09, 2013, 10:59 AM
  4. Replies: 7
    Last Post: Sep 18, 2013, 1:18 PM
  5. [CLOSED] PasswordMask information
    By CarWise in forum 2.x Premium Help
    Replies: 5
    Last Post: Sep 12, 2013, 11:32 AM

Posting Permissions