Created
July 12, 2011 22:51
-
-
Save eric/1079175 to your computer and use it in GitHub Desktop.
Hanging regex found by @jnunemaker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[1 : 0] eric@morizo:/Users/eric > irb | |
>> regex = /\A(?:%[0-9a-fA-F]{2}|[^%]+)*\z/ | |
=> /\A(?:%[0-9a-fA-F]{2}|[^%]+)*\z/ | |
>> str = "http%3A%2F%2Fwww.google.com%2Furl%3Fsa%3Dt%26source%3Dweb%26cd%3D1%26sqi%3D2%26ved%3D0CCkQFjAA%26url%3Dhttp%253A%252F%252Fnd.edu%252F%26rct%3Dj%" | |
=> "http%3A%2F%2Fwww.google.com%2Furl%3Fsa%3Dt%26source%3Dweb%26cd%3D1%26sqi%3D2%26ved%3D0CCkQFjAA%26url%3Dhttp%253A%252F%252Fnd.edu%252F%26rct%3Dj%" | |
>> regex =~ str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From https://github.com/rack/rack/blob/a50dda57c1426b6b38ed06fa08cab154285c8057/lib/rack/backports/uri/common.rb#L61 | |
regex = /\A(?:%[0-9a-fA-F]{2}|[^%]+)*\z/ | |
str = "http%3A%2F%2Fwww.google.com%2Furl%3Fsa%3Dt%26source%3Dweb%26cd%3D1%26sqi%3D2%26ved%3D0CCkQFjAA%26url%3Dhttp%253A%252F%252Fnd.edu%252F%26rct%3Dj%" | |
# This hangs for: | |
# - ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0] | |
# - ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2011.02 | |
regex =~ str |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment