#807 enhancement
Yaffle

fix Hash class to use prefix

Reported by Yaffle | September 23rd, 2009 @ 07:21 PM | in 1.7

Prefixing keys in Hash class to avoid setting 'proto', 'count', 'toString'(IE DontEnum bug), 'hasOwnProperty', ...

http://groups.google.com/group/prototype-core/browse_thread/thread/...

Comments and changes to this ticket

  • blatyo

    blatyo September 23rd, 2009 @ 08:26 PM

    Hash.escape = function(key){
    key = String(key); return (key.length

    This looks very wrong. If I do var h = new Hash(); h.set('a',1);, this would make my key 'true'. So then, if I do h.set('b',2); it would internally set 'true' to 2 and overwrite my a value. Then when I h.get('a') and h.get('b'), the keys would reference the value stored on the key 'true'.

    I would like to see some tests for this new behavior.

  • blatyo

    blatyo September 23rd, 2009 @ 08:31 PM

    My text got garbled, so I'm re-updating.

    Hash.escape = function(key){
      key = String(key);
      return (key.length<32 || key.charAt(0)==='*'? '*'+key: key);
    };
    

    This looks very wrong. If I do:

    var h = new Hash(); 
    h.set('a',1);
    

    Hash.escape would make my internal key = 'true'. So then, if I do:

    h.set('b',2);
    
    It would internally set 'true' to 2 and overwrite my a value. Then when I h.get('a') and h.get('b'), the keys would reference the value stored internally with the key 'true'.
  • Yaffle

    Yaffle September 24th, 2009 @ 06:48 PM

    key = 'a';
    key = String(key); // key === 'a'
    return (key.length

  • blatyo

    blatyo September 25th, 2009 @ 04:35 PM

    Disregard what I wrote. I misread the statement.

    +1

  • Juriy Zaytsev

    Juriy Zaytsev September 26th, 2009 @ 07:48 PM

    • Tag changed from section:lang to needs:patch, needs:tests, section:lang
    • State changed from “new” to “enhancement”
    • Milestone set to 1.7
    • Assigned user set to “Juriy Zaytsev”
  • T.J. Crowder

    T.J. Crowder November 16th, 2009 @ 04:50 PM

    • Assigned user cleared.

    [responsible:none bulk edit command]

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

Attachments

Pages