public
Fork of Caged/gitnub
Description: A Gitk-like application written in RubyCocoa that looks like it belongs on a Mac. See the wiki for downloads and screenshots.
Homepage: http://alternateidea.com
Clone URL: git://github.com/kballard/gitnub.git
Search Repo:
Escape HTML in commit messages. Fixes #22
kballard (author)
Wed May 14 02:17:15 -0700 2008
commit  019f7eab430c325acd58a548baa7856fdf69b24e
tree    ae2e9089d76466d66006f680544d11a2c54d49e8
parent  ceed7d12eaa21647294939eb24010c5aa2b2f0e0
...
13
14
15
 
16
17
18
...
13
14
15
16
17
18
19
0
@@ -13,6 +13,7 @@
0
 $:.unshift(libdir, "#{libdir}/grit/lib", "#{libdir}/mime-types/lib")
0
 require 'grit'
0
 require 'time_extensions'
0
+require 'string_hacks'
0
 require 'InfoWindowController'
0
 
0
 OSX.ns_import 'CommitSummaryCell'
...
151
152
153
154
 
155
156
 
157
158
159
...
151
152
153
 
154
155
 
156
157
158
159
0
@@ -151,9 +151,9 @@
0
     diffs = []
0
     doc = @commit_details.mainFrame.DOMDocument
0
     title, message = active_commit.message.split("\n", 2)
0
- set_html("title", title..strip.gsub("\n", "<br />"))
0
+ set_html("title", title.escapeHTML.strip.gsub("\n", "<br />"))
0
     if message
0
- set_html("message", message..strip.gsub("\n", "<br />"))
0
+ set_html("message", message.escapeHTML.strip.gsub("\n", "<br />"))
0
       show_element("message")
0
     else
0
       hide_element("message")
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
0
@@ -1 +1,20 @@
0
+class String
0
+ HTML_ESCAPES = {
0
+ ?& => "amp",
0
+ ?" => "quot",
0
+ ?< => "lt",
0
+ ?> => "gt"
0
+ }.freeze
0
+
0
+ def escapeHTML
0
+ self.split("").collect { |x| HTML_ESCAPES.key?(x.ord) ? "&#{HTML_ESCAPES[x.ord]};" : x }.join("")
0
+ end
0
+
0
+ # Ruby 1.9 forward-compatibility
0
+ unless String.method_defined?(:ord)
0
+ define_method :ord do
0
+ self[0]
0
+ end
0
+ end
0
+end

Comments

    No one has commented yet.