[LON-CAPA-cvs] cvs: loncom /interface lonbulletin.pm lonfeedback.pm lonmsgdisplay.pm lonsimplepage.pm lonsyllabus.pm lontemplate.pm
faziophi
faziophi@source.lon-capa.org
Thu, 26 Nov 2009 05:21:43 -0000
faziophi Thu Nov 26 05:21:43 2009 EDT
Modified files:
/loncom/interface lonbulletin.pm lonfeedback.pm lonmsgdisplay.pm
lonsimplepage.pm lonsyllabus.pm lontemplate.pm
Log:
Adds check before calling lonfeedback::newline_to_br to see if
the text contains block-level HTML elements (such as <table> or <p> or <br />).
If HTML is detected, newlines will no longer be automatically converted
to <br /> tags -- this resolves bugs such as 5550, where for
example, inserting a table using the WYSIWYG editor causes
erroneous break tags to be created.
Index: loncom/interface/lonbulletin.pm
diff -u loncom/interface/lonbulletin.pm:1.49 loncom/interface/lonbulletin.pm:1.50
--- loncom/interface/lonbulletin.pm:1.49 Thu Nov 19 18:05:32 2009
+++ loncom/interface/lonbulletin.pm Thu Nov 26 05:21:43 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Bulletin Board Handler
#
-# $Id: lonbulletin.pm,v 1.49 2009/11/19 18:05:32 bisitz Exp $
+# $Id: lonbulletin.pm,v 1.50 2009/11/26 05:21:43 faziophi Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -249,7 +249,9 @@
foreach my $field (sort(keys(%syllabusfields))) {
if (($syllabus{$field}) || ($allowed)) {
my $message=$syllabus{$field};
- &Apache::lonfeedback::newline_to_br(\$message);
+ if (&Apache::lonfeedback::newline_to_br($message)) {
+ &Apache::lonfeedback::newline_to_br(\$message);
+ }
$message
=~s/(https*\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
if ($allowed) {
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.279 loncom/interface/lonfeedback.pm:1.280
--- loncom/interface/lonfeedback.pm:1.279 Sat Nov 21 22:36:23 2009
+++ loncom/interface/lonfeedback.pm Thu Nov 26 05:21:43 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.279 2009/11/21 22:36:23 www Exp $
+# $Id: lonfeedback.pm,v 1.280 2009/11/26 05:21:43 faziophi Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2949,7 +2949,19 @@
);
}
-
+sub contains_block_html {
+ my ($message)=@_;
+ return ($message =~ m/
+ <(br|h1|h2|h3|h4|h5|h6|p|ol|ul|table|pre|address|blockquote|center|div)
+ [\s]*
+ ([\w]+\=['"][\w]+['"])*
+ [\s]*
+ (
+ [\s]*[\/]>|
+ >.*<\/\1[\s]*>
+ )/x );
+}
+
sub newline_to_br {
my ($message)=@_;
my $newmessage;
Index: loncom/interface/lonmsgdisplay.pm
diff -u loncom/interface/lonmsgdisplay.pm:1.138 loncom/interface/lonmsgdisplay.pm:1.139
--- loncom/interface/lonmsgdisplay.pm:1.138 Wed Nov 4 18:30:17 2009
+++ loncom/interface/lonmsgdisplay.pm Thu Nov 26 05:21:43 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging display
#
-# $Id: lonmsgdisplay.pm,v 1.138 2009/11/04 18:30:17 raeburn Exp $
+# $Id: lonmsgdisplay.pm,v 1.139 2009/11/26 05:21:43 faziophi Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1845,7 +1845,9 @@
foreach my $key (sort(keys(%records))) {
my %content=&Apache::lonmsg::unpackagemsg($records{$key});
next if ($content{'senderdomain'} eq '');
- &Apache::lonfeedback::newline_to_br(\$content{'message'});
+ if (!&Apache::lonfeedback::contains_block_html($content{'message'})) {
+ &Apache::lonfeedback::newline_to_br(\$content{'message'});
+ }
if ($content{'subject'}=~/^Record/) {
$result.='<h3>'.&mt('Record').'</h3>';
} elsif ($content{'subject'}=~/^Broadcast/) {
Index: loncom/interface/lonsimplepage.pm
diff -u loncom/interface/lonsimplepage.pm:1.85 loncom/interface/lonsimplepage.pm:1.86
--- loncom/interface/lonsimplepage.pm:1.85 Fri Jul 10 15:05:28 2009
+++ loncom/interface/lonsimplepage.pm Thu Nov 26 05:21:43 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Simple Page Editor
#
-# $Id: lonsimplepage.pm,v 1.85 2009/07/10 15:05:28 bisitz Exp $
+# $Id: lonsimplepage.pm,v 1.86 2009/11/26 05:21:43 faziophi Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -333,7 +333,9 @@
if (($syllabus{$field}) || ($allowed) ||
($field eq 'abb_links' && $group ne '')) {
my $message=$syllabus{$field};
- &Apache::lonfeedback::newline_to_br(\$message);
+ if (!&Apache::lonfeedback::contains_block_html($message)) {
+ &Apache::lonfeedback::newline_to_br(\$message);
+ }
$message=~s/(https*\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
if ($allowed) {
$message=&Apache::lonspeller::markeduptext($message);
Index: loncom/interface/lonsyllabus.pm
diff -u loncom/interface/lonsyllabus.pm:1.100 loncom/interface/lonsyllabus.pm:1.101
--- loncom/interface/lonsyllabus.pm:1.100 Fri Oct 23 16:14:43 2009
+++ loncom/interface/lonsyllabus.pm Thu Nov 26 05:21:43 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Syllabus
#
-# $Id: lonsyllabus.pm,v 1.100 2009/10/23 16:14:43 bisitz Exp $
+# $Id: lonsyllabus.pm,v 1.101 2009/11/26 05:21:43 faziophi Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -415,7 +415,9 @@
$r->print($message);
}
} else {
- &Apache::lonfeedback::newline_to_br(\$message);
+ if (!&Apache::lonfeedback::contains_block_html($message)) {
+ &Apache::lonfeedback::newline_to_br(\$message);
+ }
$message =~s|(https?\://[^\s]+)|<a href="$1"><tt>$1</tt></a>|g;
if ($allowed) {
$message=&Apache::lonspeller::markeduptext($message);
Index: loncom/interface/lontemplate.pm
diff -u loncom/interface/lontemplate.pm:1.39 loncom/interface/lontemplate.pm:1.40
--- loncom/interface/lontemplate.pm:1.39 Fri Oct 16 13:47:40 2009
+++ loncom/interface/lontemplate.pm Thu Nov 26 05:21:43 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# "Template" Functions to generate html output
#
-# $Id: lontemplate.pm,v 1.39 2009/10/16 13:47:40 raeburn Exp $
+# $Id: lontemplate.pm,v 1.40 2009/11/26 05:21:43 faziophi Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -62,7 +62,9 @@
foreach my $field (sort(keys(%syllabusfields))) {
if (($syllabus{$field}) || ($allowed)) {
my $message=$syllabus{$field};
- &Apache::lonfeedback::newline_to_br(\$message);
+ if (!&Apache::lonfeedback::contains_block_html($message)) {
+ &Apache::lonfeedback::newline_to_br(\$message);
+ }
$message
=~s/(http\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
if ($allowed) {