Skip to content

Instantly share code, notes, and snippets.

/test.rb Secret

Created September 23, 2015 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/21fbd9127158a2c79e94 to your computer and use it in GitHub Desktop.
Save anonymous/21fbd9127158a2c79e94 to your computer and use it in GitHub Desktop.
irb(main):075:0> foo = File.read('307839-2.xhtml')
=> "<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n<title>Testcase bug - Evil mrow:hover testcase crashes Mozilla</title>\r\n<style type=\"text/css\">\r\n</html>\r\n"
irb(main):076:0> bar = File.read('replace.txt')
=> "'canPlayType':{'ret':'none', 'args':[{'choice':['video/mp4; codecs=\\'avc1.42E01E\\'', 'video/ogg; codecs=\\'theora\\'']}]},\n"
irb(main):077:0> print foo.sub(/<head>/m, "\0\n<script type='text/javascript'>" + bar + "</script>")
<html xmlns="http://www.w3.org/1999/xhtml">
<script type='text/javascript'>'canPlayType':{'ret':'none', 'args':[{'choice':['video/mp4; codecs=
<title>Testcase bug - Evil mrow:hover testcase crashes Mozilla</title>
<style type="text/css">
</html>
avc1.42E01E
<title>Testcase bug - Evil mrow:hover testcase crashes Mozilla</title>
<style type="text/css">
</html>
', 'video/ogg; codecs=
<title>Testcase bug - Evil mrow:hover testcase crashes Mozilla</title>
<style type="text/css">
</html>
theora
<title>Testcase bug - Evil mrow:hover testcase crashes Mozilla</title>
<style type="text/css">
</html>
']}]},
</script>
<title>Testcase bug - Evil mrow:hover testcase crashes Mozilla</title>
<style type="text/css">
</html>
=> nil
irb(main):078:0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment