Vos Regexps sont fausses !

364 views
328 views

Published on

Je montre ici une simple mesure de sécurité concernant les expressions régulières de validation.

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
364
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Vos Regexps sont fausses !

    1. 1. Vos RegExps sont fausses ! Simon COURTOIS - @happynoff
    2. 2. ^...$
    3. 3. ^...$class User < ActiveRecord::Base attr_accessible :email validates :email, presence: true, uniqueness: true, format: { with: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}$/i }endhttp://www.regular-expressions.info/email.html
    4. 4. ^...$toto@exemple.fr ✔totoexemple.fr ✗hellototo@exemple.fr ✔hello
    5. 5. ^...$
    6. 6. ˆ...$http://ruby-doc.org/core-1.9.3/Regexp.html Anchors ^ - Matches beginning of line $ - Matches end of line
    7. 7. ^...$➜ hello➜ totoexemple.fr➜ hello
    8. 8. A...Zhttp://ruby-doc.org/core-1.9.3/Regexp.html Anchors ^ - Matches beginning of line $ - Matches end of line A - Matches beginning of string Z - Matches end of string
    9. 9. A...Zclass User < ActiveRecord::Base attr_accessible :email validates :email, presence: true, uniqueness: true, format: { with: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}$/i }end
    10. 10. A...Zclass User < ActiveRecord::Base attr_accessible :email validates :email, presence: true, uniqueness: true, format: { with: /A[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}Z/i }end
    11. 11. A...Ztoto@exemple.fr ✔totoexemple.fr ✗hellototoexemple.fr ✗hello
    12. 12. A...Z
    13. 13. Merci !Simon COURTOIS - @happynoff

    ×