--- loncom/interface/londocs.pm 2020/03/12 07:40:51 1.484.2.88
+++ loncom/interface/londocs.pm 2021/12/22 01:22:06 1.484.2.93
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.484.2.88 2020/03/12 07:40:51 raeburn Exp $
+# $Id: londocs.pm,v 1.484.2.93 2021/12/22 01:22:06 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -177,6 +177,45 @@ sub default_folderpath {
}
}
+sub validate_folderpath {
+ my ($supplementalflag) = @_;
+ if ($env{'form.folderpath'} ne '') {
+ my @items = split(/\&/,$env{'form.folderpath'});
+ my $badpath;
+ for (my $i=0; $i<@items; $i++) {
+ my $odd = $i%2;
+ if (($odd) && (!$supplementalflag) && ($items[$i] !~ /^[^:]*:(|\d+):(|1):(|1):(|1):(|1)$/)) {
+ $badpath = 1;
+ } elsif ((!$odd) && ($items[$i] !~ /^(default|supplemental)(|_\d+)$/)) {
+ $badpath = 1;
+ }
+ last if ($badpath);
+ }
+ if ($badpath) {
+ delete($env{'form.folderpath'});
+ }
+ }
+ return;
+}
+
+sub validate_suppath {
+ if ($env{'form.supppath'} ne '') {
+ my @items = split(/\&/,$env{'form.supppath'});
+ my $badpath;
+ for (my $i=0; $i<@items; $i++) {
+ my $odd = $i%2;
+ if ((!$odd) && ($items[$i] !~ /^supplemental(|_\d+)$/)) {
+ $badpath = 1;
+ }
+ last if ($badpath);
+ }
+ if ($badpath) {
+ delete($env{'form.supppath'});
+ }
+ }
+ return;
+}
+
sub dumpcourse {
my ($r) = @_;
my $crstype = &Apache::loncommon::course_type();
@@ -676,26 +715,27 @@ sub group_import {
}
my $ext = 'false';
if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
- $name = &LONCAPA::map::qtunescape($name);
- if ($name eq '') {
- $name = &LONCAPA::map::qtunescape(&mt('Web Page'));
- }
if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) {
my $filepath = $1;
- my $fname = $name;
- if ($fname =~ /^\W+$/) {
+ my $fname;
+ if ($name eq '') {
+ $name = &mt('Web Page');
$fname = 'web';
} else {
- $fname =~ s/\W/_/g;
- }
- if (length($fname) > 15) {
- $fname = substr($fname,0,14);
+ $fname = $name;
+ $fname=&Apache::lonnet::clean_filename($fname);
+ if ($fname eq '') {
+ $fname = 'web';
+ } elsif (length($fname) > 15) {
+ $fname = substr($fname,0,14);
+ }
}
+ my $title = &Apache::loncommon::cleanup_html($name);
my $initialtext = &mt('Replace with your own content.');
my $newhtml = <
-$name
+$title
$initialtext
@@ -717,6 +757,7 @@ END
return (&mt('Failed to save new web page.'),1);
}
}
+ $name = &LONCAPA::map::qtunescape($name);
$url = &LONCAPA::map::qtunescape($url);
$LONCAPA::map::resources[$residx] =
join(':', ($name, $url, $ext, 'normal', 'res'));
@@ -3921,7 +3962,7 @@ END
} elsif ($url eq "/public/$coursedom/$coursenum/syllabus") {
if (($ENV{'SERVER_PORT'} == 443) &&
($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
- unless (&Apache::lonnet::uses_sts()) {
+ unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
$url .= '?usehttp=1';
}
$nomodal = 1;
@@ -3986,7 +4027,7 @@ END
$url = $1;
$anchor = $2;
if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) {
- unless (&Apache::lonnet::uses_sts()) {
+ unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
if ($hostname ne '') {
$url = 'http://'.$hostname.$url;
}
@@ -3998,7 +4039,7 @@ END
} elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
if (($ENV{'SERVER_PORT'} == 443) &&
($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
- unless (&Apache::lonnet::uses_sts()) {
+ unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
if ($hostname ne '') {
$url = 'http://'.$hostname.$url;
}
@@ -4549,7 +4590,7 @@ sub contentverifyform {
&mt('No').''.(' 'x2).
'
'.
- ''.
+ ''.
''.
'
');
$r->print(&endContentScreen());
@@ -5137,35 +5178,11 @@ sub handler {
if ($env{'form.tools'}) { $toolsflag=1; }
if ($env{'form.folderpath'} ne '') {
- my @items = split(/\&/,$env{'form.folderpath'});
- my $badpath;
- for (my $i=0; $i<@items; $i++) {
- my $odd = $i%2;
- if (($odd) && (!$supplementalflag) && ($items[$i] !~ /^[^:]*:(|\d+):(|1):(|1):(|1):(|1)$/)) {
- $badpath = 1;
- } elsif ((!$odd) && ($items[$i] !~ /^(default|supplemental)(|_\d+)$/)) {
- $badpath = 1;
- }
- last if ($badpath);
- }
- if ($badpath) {
- delete($env{'form.folderpath'});
- }
+ &validate_folderpath($supplementalflag);
}
if ($env{'form.supppath'} ne '') {
- my @items = split(/\&/,$env{'form.supppath'});
- my $badpath;
- for (my $i=0; $i<@items; $i++) {
- my $odd = $i%2;
- if ((!$odd) && ($items[$i] !~ /^supplemental(|_\d+)$/)) {
- $badpath = 1;
- }
- last if ($badpath);
- }
- if ($badpath) {
- delete($env{'form.supppath'});
- }
+ &validate_suppath();
}
my $script='';
@@ -5223,6 +5240,9 @@ sub handler {
} else {
undef($env{'form.folderpath'});
}
+ if ($env{'form.folderpath'} ne '') {
+ &validate_folderpath($supplementalflag);
+ }
}
# If we are not allowed to make changes, all we can see are supplemental docs
@@ -5900,13 +5920,19 @@ NSYLFORM
$help{'Group Portfolio'}
NGFFORM
- @specialdocumentsforma=(
+ if ($container eq 'page') {
+ @specialdocumentsforma=(
+ {'
'=>$newwebpageform},
+ );
+ } else {
+ @specialdocumentsforma=(
{'
'=>$newpageform},
{'
'=>$newsylform},
{'
'=>$newnavform},
{'
'=>$newsmppageform},
{'
'=>$newwebpageform},
- );
+ );
+ }
$specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
@@ -5944,11 +5970,11 @@ my %orderhash = (
'aa' => ['Upload',$fileuploadform],
'bb' => ['Import',$importpubform],
'cc' => ['Grading',$gradingform],
+ 'ee' => ['Other',$specialdocumentsform],
);
unless ($container eq 'page') {
$orderhash{'00'} = ['Newfolder',$newfolderform];
$orderhash{'dd'} = ['Collaboration',$communityform];
- $orderhash{'ee'} = ['Other',$specialdocumentsform];
}
$hadchanges=0;
@@ -6576,7 +6602,7 @@ sub editing_js {
if ($backtourl =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
if (($ENV{'SERVER_PORT'} == 443) &&
($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
- unless (&Apache::lonnet::uses_sts()) {
+ unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
if ($hostname ne '') {
$backtourl = 'http://'.$hostname.$backtourl;
}
@@ -6585,7 +6611,7 @@ sub editing_js {
}
} elsif ($backtourl =~ m{^/adm/wrapper/ext/(?!https:)}) {
if (($ENV{'SERVER_PORT'} == 443) && ($hostname ne '')) {
- unless (&Apache::lonnet::uses_sts()) {
+ unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
if ($hostname ne '') {
$backtourl = 'http://'.$hostname.$backtourl;
}
@@ -6623,7 +6649,7 @@ sub editing_js {
function makenewfolder(targetform,folderseq) {
var foldername=prompt('$js_lt{"p_mnf"}','$js_lt{"t_mnf"}');
if (foldername) {
- targetform.importdetail.value=escape(foldername)+"="+folderseq;
+ targetform.importdetail.value=encodeURIComponent(foldername)+"="+folderseq;
targetform.submit();
}
}
@@ -6631,7 +6657,7 @@ function makenewfolder(targetform,folder
function makenewpage(targetform,folderseq) {
var pagename=prompt('$js_lt{"p_mnp"}','$js_lt{"t_mnp"}');
if (pagename) {
- targetform.importdetail.value=escape(pagename)+"="+folderseq;
+ targetform.importdetail.value=encodeURIComponent(pagename)+"="+folderseq;
targetform.submit();
}
}
@@ -6640,7 +6666,7 @@ function makeexamupload() {
var title=prompt('$js_lt{"p_mxu"}');
if (title) {
this.document.forms.newexamupload.importdetail.value=
- escape(title)+'=/res/lib/templates/examupload.problem';
+ encodeURIComponent(title)+'=/res/lib/templates/examupload.problem';
this.document.forms.newexamupload.submit();
}
}
@@ -6649,7 +6675,7 @@ function makesmppage() {
var title=prompt('$js_lt{"p_msp"}');
if (title) {
this.document.forms.newsmppg.importdetail.value=
- escape(title)+'=/adm/$udom/$uname/new/smppg';
+ encodeURIComponent(title)+'=/adm/$udom/$uname/new/smppg';
this.document.forms.newsmppg.submit();
}
}
@@ -6664,7 +6690,7 @@ function makewebpage(type) {
}
if (title) {
var webpage = formname.importdetail.value;
- formname.importdetail.value = escape(title)+'='+webpage;
+ formname.importdetail.value = encodeURIComponent(title)+'='+webpage;
formname.submit();
}
}
@@ -6673,7 +6699,7 @@ function makesmpproblem() {
var title=prompt('$js_lt{"p_msb"}');
if (title) {
this.document.forms.newsmpproblem.importdetail.value=
- escape(title)+'=/res/lib/templates/simpleproblem.problem';
+ encodeURIComponent(title)+'=/res/lib/templates/simpleproblem.problem';
this.document.forms.newsmpproblem.submit();
}
}
@@ -6682,7 +6708,7 @@ function makedropbox() {
var title=prompt('$js_lt{"p_mdb"}');
if (title) {
this.document.forms.newdropbox.importdetail.value=
- escape(title)+'=/res/lib/templates/DropBox.problem';
+ encodeURIComponent(title)+'=/res/lib/templates/DropBox.problem';
this.document.forms.newdropbox.submit();
}
}
@@ -6691,7 +6717,7 @@ function makebulboard() {
var title=prompt('$js_lt{"p_mbb"}');
if (title) {
this.document.forms.newbul.importdetail.value=
- escape(title)+'=/adm/$udom/$uname/new/bulletinboard';
+ encodeURIComponent(title)+'=/adm/$udom/$uname/new/bulletinboard';
this.document.forms.newbul.submit();
}
}