Log Message:
-----------
backport (dpvc): Fix DOS and Mac line endings, and make the detection of
non-text files a little more strict (DOS files were being marked as
non-text). Also, localize the file handles.
Tags:
----
rel-2-4-dev
Modified Files:
--------------
webwork2/lib/WeBWorK/ContentGenerator/Instructor:
FileManager.pm
Revision Data
-------------
Index: FileManager.pm
===================================================================
RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Instructor/FileManager.pm,v
retrieving revision 1.26.2.3
retrieving revision 1.26.2.4
diff -Llib/WeBWorK/ContentGenerator/Instructor/FileManager.pm -Llib/WeBWorK/ContentGenerator/Instructor/FileManager.pm -u -r1.26.2.3 -r1.26.2.4
--- lib/WeBWorK/ContentGenerator/Instructor/FileManager.pm
+++ lib/WeBWorK/ContentGenerator/Instructor/FileManager.pm
@@ -472,6 +472,8 @@
my $data = $self->r->param("data");
if (defined($data)) {
+ $data =~ s/\r\n?/\n/g; # convert DOS and Mac line ends to unix
+ local (*OUTFILE);
if (open(OUTFILE,">$file")) {
eval {print OUTFILE $data; close(OUTFILE)};
if ($@) {$self->addbadmessage("Failed to save: $@")}
@@ -745,6 +747,7 @@
if ($self->r->param('confirmed')) {
my $name = $self->r->param('name');
if (my $file = $self->verifyName($name,"file")) {
+ local (*NEWFILE);
if (open(NEWFILE,">$file")) {
close(NEWFILE);
$self->RefreshEdit("",$name);
@@ -1186,12 +1189,12 @@
##################################################
#
# Check if a string is plain text
-# (i.e., doesn't contain three non-regular
+# (i.e., doesn't contain four non-regular
# characters in a row.)
#
sub isText {
my $string = shift;
- return $string !~ m/[^\s\x20-\x7E]{3,}/;
+ return $string !~ m/[^\s\x20-\x7E]{4}/;
}
##################################################
|