格式化用户提交的HTML代码
Reported by yuanyi | 2009-10-24 00:24:01 UTC | in 1.0.7
参看这个: http://www.1kg.org/shares/1000581
用户提交的错误HTML代码导致样式页面样式错误.
doc = Nokogiri::HTML.parse("
hello world
")doc.at("/html/body").inner_html
=> "
hello world
"Comments and changes to this ticket
-

suave 2009-11-05 17:12:30 UTC
- Milestone changed from 1.0.4 to 1.0.5
[milestone:id#54873 bulk edit command]
-

-

-

-

yuanyi 2009-12-03 10:05:56 UTC
- Assigned user set to yuanyi
用Sanitize试了一下,效果很好,测试的Filter是:
Sanitize.clean(@share.body_html, :elements => ['a', 'div', 'img', 'p', 'embed'], :attributes => {'a' => ['href', 'title'], 'img' => ['src', 'alt', 'title']}, :protocols => {'a' => {'href' => ['http', 'https', 'mailto']}})不知道有没遗漏的标签?
-

-

yuanyi 2009-12-03 11:42:22 UTC
加上了FCK的标签,现在是,p也有style,但是是用来左右对齐的,貌似没有这个需求,先不加了:
Sanitize.clean(html, :elements => ['a', 'div', 'span', 'img', 'p', 'embed', 'em', 'ol', 'ul', 'li'], :attributes => {'a' => ['href', 'title'], 'img' => ['src', 'alt', 'title'], 'span' => ['style']}, :protocols => {'a' => {'href' => ['http', 'https', 'mailto']}}) -

-

yuanyi 2009-12-03 11:59:26 UTC
- State changed from new to resolved
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »