Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 171
- Log:
Initial import of Beast 0.9 from downloaded Tarball. Beast is a Ruby
On Rails based forum application. The original tarball came from the
following location:http://s3.amazonaws.com/beast-forum/beast-0.9.tar.gz
The forum post which announced this version's availability was at:
http://beast.caboo.se/forums/1/topics/446
- Author:
- rool
- Date:
- Fri Mar 02 15:51:55 +0000 2007
- Size:
- 2020 Bytes
1 | module WhiteListHelper |
2 | PROTOCOL_ATTRIBUTES = %w(src href) |
3 | PROTOCOL_SEPARATOR = /:|(�*58)|(p)|(%|%)3A/ |
4 | mattr_reader :tags, :attributes, :protocols |
5 | @@tags = %w(strong em b i p code pre tt output samp kbd var sub sup dfn cite big small address hr br div span h1 h2 h3 h4 h5 h6 ul ol li dt dd) |
6 | @@attributes = { |
7 | 'a' => %w(href), |
8 | 'img' => %w(src width height alt), |
9 | 'blockquote' => %w(cite), |
10 | 'del' => %w(cite datetime), |
11 | 'ins' => %w(cite datetime), |
12 | nil => %w(id class) } |
13 | @@protocols = %w(ed2k ftp http https irc mailto news gopher nntp telnet webcal xmpp callto feed) |
14 | |
15 | def white_listed_tags |
16 | ::WhiteListHelper.tags |
17 | end |
18 | |
19 | def white_listed_attributes |
20 | ::WhiteListHelper.attributes |
21 | end |
22 | |
23 | def white_listed_protocols |
24 | ::WhiteListHelper.protocols |
25 | end |
26 | |
27 | def white_list(html) |
28 | return html if html.blank? || !html.include?('<') |
29 | returning [] do |new_text| |
30 | tokenizer = HTML::Tokenizer.new(html) |
31 | |
32 | while token = tokenizer.next |
33 | node = HTML::Node.parse(nil, 0, 0, token, false) |
34 | new_text << case node |
35 | when HTML::Tag |
36 | unless (white_listed_tags + white_listed_attributes.keys).include?(node.name) |
37 | node.to_s.gsub(/</, "<") |
38 | else |
39 | if node.closing != :close |
40 | attributes = (white_listed_attributes[nil] || []) + (white_listed_attributes[node.name] || []) |
41 | node.attributes.delete_if do |attr_name, value| |
42 | !attributes.include?(attr_name) || (PROTOCOL_ATTRIBUTES.include?(attr_name) && contains_bad_protocols?(value)) |
43 | end if attributes.any? |
44 | end |
45 | node.to_s |
46 | end |
47 | else |
48 | node.to_s.gsub(/</, "<") |
49 | end |
50 | end |
51 | end.join |
52 | end |
53 | |
54 | private |
55 | def contains_bad_protocols?(value) |
56 | value =~ PROTOCOL_SEPARATOR && !white_listed_protocols.include?(value.split(PROTOCOL_SEPARATOR).first) |
57 | end |
58 | end |