Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HtmlFormatter#replace_urls explodes on certain inputs #75

Closed
tvdstaaij opened this issue Mar 4, 2017 · 0 comments
Closed

HtmlFormatter#replace_urls explodes on certain inputs #75

tvdstaaij opened this issue Mar 4, 2017 · 0 comments
Labels

Comments

@tvdstaaij
Copy link
Owner

Example testcase that triggers the bug:

require_relative 'formatters/html'

text = 'try { _local3 = _arg1; while (_local3 != null) { if (((((_local3.parent) && (_local3.stage))) && ((_local3.parent == _local3.stage)))){ break; }; _local4 = ((((("id" in _local3)) && (_local3["id"]))) ? _local3["id"] : _local3.name); if ((_local3 is IRepeaterClient)){ _local5 = IRepeaterClient(_local3).instanceIndices; if (_local5){ _local4 = (_local4 + (("[" + _local5.join("][")) + "]")); }; }; _local2 = (((_local2 == null)) ? _local4 : ((_local4 + ".") + _local2)); _local3 = _local3.parent; }; } catch(e:SecurityError) { }; return (_local2); } public static function getUnqualifiedClassName(_arg1:object):string{ var _local2:string; if ((_arg1 is string)){ _local2 = (_arg1 as string); } else { _local2 = getQualifiedClassName(_arg1); }; var _local3:int = _local2.indexof("::"); if (_local3 != -1){ _local2 = _local2.substr((_local3 + 2)); }; return (_local2); } } }//package mx.utils package { import flash.display.*; import flash.text.*; public dynamic class SaleIconTooltip extends movieclip { public var tipText:textfield; } }//package package { import flash.display.*; public dynamic class StarIcon extends movieclip { public var iconTooltip:StarIconTooltip; public function StarIcon(){ addFrameScript(0, this.frame1, 1, this.frame2); } function frame1(){ stop(); } function frame2(){ stop(); } } }//package package { import flash.display.*; public dynamic class InfoIcon extends movieclip { } }//package package { import flash.display.*; public dynamic class songList extends movieclip { public var rowList_mc:movieclip; } }//package package { import flash.display.*; public dynamic class CurrencyList extends movieclip { public var close_mc:DialogClose; } }//package package { import flash.display.*; public dynamic class PostCommentButton extends movieclip { } }//package package { import flash.display.*; public dynamic class LicenseSelectedBackground extends movieclip { } }//package package { import flash.display.*; public dynamic class PlusIcon extends movieclip { public var iconTooltip:PlusIconTooltip; public function PlusIcon(){ addFrameScript(0, this.frame1, 1, this.frame2); } function frame1(){ stop(); } function frame2(){ stop(); } } }//package package { import flash.display.*; import flash.text.*; public dynamic class songRowWhite extends movieclip { public var bpm_txt:textfield; public var genre_txt:textfield; public var inactiveBG:movieclip; public var name_txt:textfield; public var price_txt:textfield; public var producer_txt:textfield; public var time_txt:textfield; } }//package package { import flash.display.*; public dynamic class FacebookIcon extends movieclip { } }//package package { import flash.display.*; public dynamic class discountMC extends movieclip { } }//package package { import flash.display.*; public dynamic class Dialog extends movieclip { } }//package package { import flash.display.*; public dynamic class TwitterIcon extends movieclip { } }//package package { import flash.display.*; import flash.text.*; public dynamic class PlusIconTooltip extends movieclip { public var tipText:textfield; } }//package package { import flash.display.*; import flash.text.*; public dynamic class PasteURL extends movieclip { public var close_mc:movieclip; public var copy_mc:movieclip; public var message_txt:textfield; public var url_txt:textfield; } }//package package { import flash.display.*; public dynamic class ScrollbarScroller extends movieclip { } }//package package { import flash.display.*; import flash.text.*; public dynamic class CouponsDialog extends movieclip { public var apply_mc:movieclip; public var close_mc:DialogClose; public var code_txt:textfield; public var loading_mc:movieclip; public var message_txt:textfield; } }//package package { import flash.display.*; public dynamic class BuyButtonBackground extends movieclip { } }//package package { import flash.display.*; public dynamic class rowActiveBackground extends movieclip { } }//package package { import flash.text.*; public dynamic class Font2 extends font { } }//package package com.greensock { import flash.events.*;';

print HtmlFormatter.new({}).replace_urls(text)

# Crashes with:
# formatters/html.rb:320:in `gsub': failed to allocate memory (NoMemoryError)
#	from formatters/html.rb:320:in `block in replace_urls'
#	from formatters/html.rb:265:in `each'
#	from formatters/html.rb:265:in `replace_urls'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant