Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CarnetApp/CarnetNextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhie <phie@phie.ovh>2018-12-04 17:42:51 +0300
committerPhie <phie@phie.ovh>2018-12-04 17:42:51 +0300
commitbd297a50324210cea92238ff8597693499f5ee88 (patch)
tree6071d94b447c97d05113585b5b74d908c20e7b7e
parent2db4f8a2146aaa0776dbf282b7ea9917445271ff (diff)
invalidate cache with mtimev0.10.4
-rwxr-xr-xappinfo/info.xml2
-rwxr-xr-xtemplates/index.php17
-rwxr-xr-xtemplates/writer.php10
3 files changed, 19 insertions, 10 deletions
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 2cfefb6..c1b03c1 100755
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -18,7 +18,7 @@ Mac, with sync capabilities
- Statistics : words/sentences/characters
- Sync with NextCloud
- Online editor as a NextCloud App]]></description>
- <version>0.10.0</version>
+ <version>0.10.4</version>
<licence>agpl</licence>
<author mail="phie@phie.ovh" >Phie</author>
<namespace>Carnet</namespace>
diff --git a/templates/index.php b/templates/index.php
index 9a7ff40..a6375bd 100755
--- a/templates/index.php
+++ b/templates/index.php
@@ -1,5 +1,6 @@
<?php
-
+global $currentpath;
+global $root;
$currentpath = __DIR__."/CarnetElectron/";
$root = \OCP\Util::linkToAbsolute("carnet","templates");
if(strpos($root,"http://") === 0 && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'){
@@ -10,18 +11,20 @@ $file = file_get_contents($currentpath."index.html");
//
$file = str_replace("href=\"","href=\"".$root."/CarnetElectron/",$file);
-preg_match_all('/<script.*?src=\"(.*?\.js(?:\?.*?)?)"/si', $file, $matches, PREG_PATTERN_ORDER);
-for ($i = 0; $i < count($matches[1]); $i++) {
- script("carnet","../templates/CarnetElectron/".substr($matches[1][$i],0,-3)."?t=".time());
-}
+
+$file = preg_replace_callback('/<script(.*?)src=\"(.*?\.js(?:\?.*?)?)"/s',function ($matches) {
+ global $currentpath;
+
+ return "<script".$matches[1]."src=\"".$matches[2]."?mtime=".filemtime($currentpath.$matches[2])."\"";
+}, $file);
+
if($_['carnet_display_fullscreen']==="yes")
script("carnet","../templates/CarnetElectron/compatibility/nextcloud/browser_fullscreen");
else {
if($_['nc_version']>=14)
style("carnet","../templates/CarnetElectron/compatibility/nextcloud/nc14-header");
}
-$file = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $file);
-$file = str_replace("src=\"","defer src=\"".$root."/CarnetElectron/",$file);
+$file = str_replace("src=\"","defer nonce='".\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()."' src=\"".$root."/CarnetElectron/",$file);
echo $file;
echo "<span style=\"display:none;\" id=\"root-url\">".$root."/CarnetElectron/</span>";
?> \ No newline at end of file
diff --git a/templates/writer.php b/templates/writer.php
index b0f0e99..ee6606d 100755
--- a/templates/writer.php
+++ b/templates/writer.php
@@ -1,4 +1,6 @@
<?php
+global $currentpath;
+global $root;
$currentpath = __DIR__."/CarnetElectron/";
$root = \OCP\Util::linkToAbsolute("carnet","templates");
if(strpos($root,"http://") === 0 && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'){
@@ -6,12 +8,16 @@ if(strpos($root,"http://") === 0 && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS
$root = "https".substr($root,strlen("http"));
}
$file = file_get_contents($currentpath."reader/reader.html");
-$file = str_replace("<!ROOTPATH>", $root."/CarnetElectron/", $file);
$file = preg_replace_callback('/<script(.*?)src=\"(.*?\.js(?:\?.*?)?)"/s',function ($matches) {
global $currentpath;
- return "<script".$matches[1]."src=\"".$matches[2]."?mtime=".filemtime($currentpath.$matches[2])."\"";
+ global $root;
+ $src = str_replace("<!ROOTPATH>", $root."/CarnetElectron/", $matches[2]);
+ $relativePath = str_replace("<!ROOTPATH>", "", $matches[2]);
+ return "<script".$matches[1]."src=\"".$src."?mtime=".filemtime($currentpath.$relativePath)."\"";
}, $file);
+$file = str_replace("<!ROOTPATH>", $root."/CarnetElectron/", $file);
+
$root = substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT']));
$urlGenerator = \OC::$server->getURLGenerator();
$file = str_replace("<!ROOTURL>", $root."/CarnetElectron/", $file);