Merge branch 'seeddms-5.1.x' into seeddms-6.0.x

This commit is contained in:
Uwe Steinmann 2020-09-15 12:14:56 +02:00
commit 630fefa3a8
10 changed files with 162 additions and 12 deletions

View File

@ -176,6 +176,7 @@
- fix import of users
- major rework of scripts in utils, unify reading of settings, use PHP_EOL
- allow inline editing of document name
- import of users does not issue an error if a group column isn't set
--------------------------------------------------------------------------------
Changes in version 5.1.19

View File

@ -10,7 +10,7 @@ EXTENSIONS := \
example.tar.gz\
tbs_template.tar.gz
PHPDOC=~/Downloads/phpDocumentor-2.8.1/bin/phpdoc
PHPDOC=~/Downloads/phpDocumentor.phar
dist:
mkdir -p tmp/seeddms-$(VERSION)
@ -69,4 +69,4 @@ doc:
apidoc:
apigen generate -s SeedDMS_Core --exclude tests -d html
.PHONY: webdav webapp repository
.PHONY: doc webdav webapp repository

View File

@ -51,7 +51,7 @@ $EXT_CONF['example'] = array(
'constraints' => array(
'depends' => array('php' => '5.6.40-', 'seeddms' => '5.1.0-'),
),
'icon' => 'icon.png',
'icon' => 'icon.svg',
'changelog' => 'changelog.md',
'class' => array(
'file' => 'class.example.php',

Binary file not shown.

Before

Width:  |  Height:  |  Size: 845 B

111
ext/example/icon.svg Normal file
View File

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="46.396889mm"
height="46.075855mm"
viewBox="0 0 46.396889 46.075855"
version="1.1"
id="svg2387"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
sodipodi:docname="seeddms-favicon-final.svg"
inkscape:export-filename="/tmp/favicon.png"
inkscape:export-xdpi="17.640476"
inkscape:export-ydpi="17.640476">
<defs
id="defs2381" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.1251953"
inkscape:cx="-19.788292"
inkscape:cy="24.95827"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-top="1"
fit-margin-left="1"
fit-margin-right="1"
fit-margin-bottom="1"
inkscape:window-width="1920"
inkscape:window-height="1023"
inkscape:window-x="0"
inkscape:window-y="33"
inkscape:window-maximized="1" />
<metadata
id="metadata2384">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-48.520586,-109.36103)">
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000e7c;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect1143-3-6-4"
width="17.821022"
height="17.821022"
x="50.185322"
y="110.70477"
inkscape:tile-cx="-545.75183"
inkscape:tile-cy="425.55311"
inkscape:tile-w="17.821023"
inkscape:tile-h="17.821023"
inkscape:tile-x0="-554.66234"
inkscape:tile-y0="416.6426"
ry="3.1053059" />
<rect
ry="3.1053059"
inkscape:tile-y0="416.6426"
inkscape:tile-x0="-554.66234"
y="127.37463"
x="67.362831"
height="17.821022"
width="17.821022"
id="use2251"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#f57800;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
transform="rotate(7)" />
<rect
ry="3.1053059"
inkscape:tile-y0="416.6426"
inkscape:tile-x0="-554.66234"
y="105.35081"
x="82.280334"
height="17.821022"
width="17.821022"
id="use2255"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.9;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#f57800;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
transform="rotate(3.5)" />
<rect
ry="3.1053059"
inkscape:tile-y0="416.6426"
inkscape:tile-x0="-554.66234"
y="117.91738"
x="100.07223"
height="17.821022"
width="17.821022"
id="use2257"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.9;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#f57800;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
transform="rotate(10.5)" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -662,6 +662,22 @@ function resolveTask($task) {
return $task;
}
/**
* Return nonce for CSP
*
* @return string
*/
function createNonce() { /* {{{ */
$length = 16;
$usable = true;
$bytes = openssl_random_pseudo_bytes($length, $usable);
if ($usable === false) {
// weak
// @TODO do something?
}
return base64_encode($bytes);
} /* }}} */
/**
* Class for creating encrypted api keys
*

View File

@ -70,6 +70,10 @@ function renderFolderData($colname, $objdata) { /* {{{ */
function getGroupData($colname, $coldata, $objdata) { /* {{{ */
global $dms;
/* explode column name to extract index of group. Actually, the whole column
* name could be used as well, as it is just a unique index in the array
* of groups.
*/
$kk = explode('_', $colname);
if(count($kk) == 2)
$gn = $kk[1];
@ -77,11 +81,15 @@ function getGroupData($colname, $coldata, $objdata) { /* {{{ */
$gn = '1';
if(!isset($objdata['groups']))
$objdata['groups'] = [];
if($group = $dms->getGroupByName($coldata)) {
$objdata['groups'][$gn] = $group;
} else {
// $objdata['groups'][$gn] = null;
$objdata['__logs__'][] = array('type'=>'error', 'msg'=> "No such group with name '".$coldata."'");
/* $coldata can be empty, if an imported users is assigned to less groups
* than group columns exists.
*/
if($coldata) {
if($group = $dms->getGroupByName($coldata)) {
$objdata['groups'][$gn] = $group;
} else {
$objdata['__logs__'][] = array('type'=>'error', 'msg'=> "No such group with name '".$coldata."'");
}
}
return $objdata;
} /* }}} */

View File

@ -157,7 +157,7 @@ if ($action == "saveSettings")
$settings->_loginFailure = intval($_POST["loginFailure"]);
$settings->_autoLoginUser = intval($_POST["autoLoginUser"]);
$settings->_quota = intval($_POST["quota"]);
$settings->_undelUserIds = is_array($_POST["undelUserIds"]) ? implode(',', $_POST["undelUserIds"]) : strval($_POST["undelUserIds"]);
$settings->_undelUserIds = !empty($_POST["undelUserIds"]) ? (is_array($_POST["undelUserIds"]) ? implode(',', $_POST["undelUserIds"]) : strval($_POST["undelUserIds"])) : '';
$settings->_encryptionKey = strval($_POST["encryptionKey"]);
$settings->_cookieLifetime = intval($_POST["cookieLifetime"]);
$settings->_defaultAccessDocs = intval($_POST["defaultAccessDocs"]);

View File

@ -118,6 +118,8 @@ $(document).ready( function() {
if($arr) {
$this->formField($arr[0], $arr[1]);
}
} elseif(is_string($arr)) {
echo $arr;
} else {
$this->formField(htmlspecialchars($attrdef->getName()), $this->getAttributeEditField($attrdef, ''));
}

View File

@ -33,6 +33,7 @@ class SeedDMS_Bootstrap_Style extends SeedDMS_View_Common {
parent::__construct($params, $theme);
$this->extraheader = array('js'=>'', 'css'=>'');
$this->footerjs = array();
$this->nonces = array();
}
/**
@ -57,11 +58,16 @@ class SeedDMS_Bootstrap_Style extends SeedDMS_View_Common {
* Content-Security-Policy since version 23+
* 'worker-src blob:' is needed for cytoscape
*/
$csp_rules = "script-src 'self' 'unsafe-eval';";
$csp_rules .= "worker-src blob:;";
$csp_rules = '';
$csp_rules .= "script-src 'self' 'unsafe-eval'";
if($this->nonces) {
$csp_rules .= " 'nonce-".implode("' 'nonce-", $this->nonces)."'";
}
$csp_rules .= ";";
$csp_rules .= " worker-src blob:;";
//$csp_rules .= "style-src 'self';";
/* Do not allow to embed myself into frames on foreigns pages */
$csp_rules .= "frame-ancestors 'self';";
$csp_rules .= " frame-ancestors 'self';";
foreach (array("X-WebKit-CSP", "X-Content-Security-Policy", "Content-Security-Policy") as $csp) {
header($csp . ": " . $csp_rules);
}
@ -145,6 +151,12 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
$this->extraheader[$type] .= $head;
} /* }}} */
function htmlAddJsHeader($script) { /* {{{ */
$nonce = createNonce();
$this->nonces[] = $nonce;
$this->extraheader['js'] .= '<script type="text/javascript" src="'.$script.'" nonce="'.$nonce.'"></script>'."\n";
} /* }}} */
function htmlEndPage($nofooter=false) { /* {{{ */
if(!$nofooter) {
$hookObjs = $this->getHookObjects('SeedDMS_View_Bootstrap');