Closed xRmg closed 7 years ago
I guess you're using 'short' URLs (without leading /index.php)? I just noticed those don't work with the current regexp used to detect share tokens.
Replacing the pattern with one which includes a non-capturing group for /index.php fixes the problem, see 2afaf051068a85c52b132cc0f109259a16c0e0be
If you can, please apply this fix - download it as a patch by appending .patch to the commit url:
https://github.com/Yetangitu/owncloud-apps/commit/2afaf051068a85c52b132cc0f109259a16c0e0be.patch
..., apply the patch in the files_reader app directory:
cd /root/of/your/nextcloud/installation/apps/files_reader
patch -p2 < /path/to/where/you/downloaded/2afaf051068a85c52b132cc0f109259a16c0e0be.patch
...and check if this fixes your problem. If you can not apply the patch for some reason it will be included in the next point release, probably today or tomorrow. The patch also includes an unrelated change needed for the upcoming version with PDF support but this should not cause any problems.
I've applied the patch but the behavior is still the same. I'm not running short url's,
I've shared a book at, link will expire in 2 days https://cloud.statix.nl/index.php/s/oCw9wbbvFdxOtRS
` 172.17.0.1 - oCw9wbbvFdxOtRS [29/Mar/2017:14:41:29 +0000] "PROPFIND /public.php/webdav/ HTTP/1.1" 207 1542 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
172.17.0.1 - - [29/Mar/2017:14:41:29 +0000] "GET /index.php/apps/gallery/config.public?extramediatypes=1&token=oCw9wbbvFdxOtRS HTTP/1.1" 200 102 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
172.17.0.1 - - [29/Mar/2017:14:41:35 +0000] "GET /index.php/apps/files_reader/?file=%2Findex.php%2Fs%2FoCw9wbbvFdxOtRS%2Fdownload%3Ffiles%3Dpg53480-images.epub%26path%3D%252F&type=application%2Fepub%2Bzip HTTP/1.1" 503 15089 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36" `
Last 3 lines of my access log Running NC 11 in docker with nginx
Unfortunately not well versed into the NC11 code but if there is anything I can change/post/check i'm glad to help
Which version of Reader are you running? Does it work when you share the file directly (the link goes to a shared directory)?
Also, there is an unrelated script (shareconfigmode1.js, this is not part of NC nor of Reader) in your first message which might be the cause of the 503 error. Which script is that, what does it do and why does it fail? Can you post the source for that script here?
Ahh yes the direct link works - https://cloud.statix.nl/index.php/s/H8q7vRQKoEMyFoE I'm running
That is the latest version. I just tested sharing a directory with some books and accessing it through an incognito window and got the same 'unknown share' error. I'll try to find the root cause of this, more l8r...
Groet'n uut Zweden...
OK, I think I'm beginning to see the reason for this problem. Accessing shared directories needs special handling which is not in Reader - yet. For now, use direct share links if you need to share a publication which should be readable online. I'll implement the needed changes in the next version.
Fixed in v1.0.3 (d8b4e395ca30d2fd065f34801402258c5f5df8b3)
Epic!, applied it as patch, works perfect! :D thanks.
I have a similar problem as xRmg. I get the same message "Unspecified share exception". Try it yourself: LINK
My system: Ubuntu 17.04 Chrome 60.0.3112.101 OC 9.1.6 (stable) Reader (ebook reader) 1.0.4
PageController.php patched:
`<?php /**
namespace OCA\Files_Reader\Controller;
use OCP\AppFramework\Controller; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\ContentSecurityPolicy; use OCP\IRequest; use OCP\IURLGenerator; use OCP\Files\IRootFolder; use OCP\Share\IManager; use OCP\Files\FileInfo; use OCP\Files\NotFoundException;
use OCA\Files_Reader\Service\BookmarkService; use OCA\Files_Reader\Service\MetadataService; use OCA\Files_Reader\Service\PreferenceService;
class PageController extends Controller {
/** @var IURLGenerator */
private $urlGenerator;
/** @var IRootFolder */
private $rootFolder;
private $shareManager;
private $userId;
private $bookmarkService;
private $metadataService;
private $preferenceService;
/**
* @param string $AppName
* @param IRequest $request
* @param IURLGenerator $urlGenerator
* @param IRootFolder $rootFolder
* @param IManager $shareManager
* @param string $UserId
* @param BookmarkService $bookmarkService
* @param PreferenceService $preferenceService
* @param MetadataService $metadataService
*/
public function __construct(
$AppName,
IRequest $request,
IURLGenerator $urlGenerator,
IRootFolder $rootFolder,
IManager $shareManager,
$UserId,
BookmarkService $bookmarkService,
PreferenceService $preferenceService,
MetadataService $metadataService) {
parent::__construct($AppName, $request);
$this->urlGenerator = $urlGenerator;
$this->rootFolder = $rootFolder;
$this->shareManager = $shareManager;
$this->userId = $UserId;
$this->bookmarkService = $bookmarkService;
$this->metadataService = $metadataService;
$this->preferenceService = $preferenceService;
}
/**
* @PublicPage
* @NoCSRFRequired
*
* @return TemplateResponse
*/
public function showReader() {
$templates= [
'application/epub+zip' => 'epubreader',
'application/x-cbr' => 'cbreader'
];
/**
* $fileInfo = [
* fileId => null,
* fileName => null,
* fileType => null
* ];
*/
$fileInfo = $this->getFileInfo($this->request->get['file']);
$fileId = $fileInfo['fileId'];
$type = $this->request->get["type"];
$scope = $template = $templates[$type];
$params = [
'urlGenerator' => $this->urlGenerator,
'downloadLink' => $this->request->get['file'],
'scope' => $scope,
'fileId' => $fileInfo['fileId'],
'fileName' => $fileInfo['fileName'],
'fileType' => $fileInfo['fileType'],
'cursor' => $this->toJson($this->bookmarkService->getCursor($fileId)),
'defaults' => $this->toJson($this->preferenceService->getDefault($scope)),
'preferences' => $this->toJson($this->preferenceService->get($scope, $fileId)),
'defaults' => $this->toJson($this->preferenceService->getDefault($scope)),
'metadata' => $this->toJson($this->metadataService->get($fileId)),
'annotations' => $this->toJson($this->bookmarkService->get($fileId))
];
$policy = new ContentSecurityPolicy();
$policy->addAllowedStyleDomain('\'self\'');
$policy->addAllowedStyleDomain('blob:');
$policy->addAllowedScriptDomain('\'self\'');
$policy->addAllowedFrameDomain('\'self\'');
$policy->addAllowedChildSrcDomain('\'self\'');
$policy->addAllowedFontDomain('\'self\'');
$policy->addAllowedFontDomain('data:');
$policy->addAllowedImageDomain('blob:');
$response = new TemplateResponse($this->appName, $template, $params, 'blank');
$response->setContentSecurityPolicy($policy);
return $response;
}
/**
* @brief sharing-aware file info retriever
*
* Work around the differences between normal and shared file access
* (this should be abstracted away in OC/NC IMnsHO)
*
* @param string $path path-fragment from url
* @return array
* @throws NotFoundException
*/
private function getFileInfo($path) {
$count = 0;
$shareToken = preg_replace("/(?:\/index\.php)?\/s\/([A-Za-z0-9]{15})\/download.*/", "$1", $path, 1,$count);
if ($count === 1) {
/* shared file or directory */
$node = $this->shareManager->getShareByToken($shareToken)->getNode();
$type = $node->getType();
/* shared directory, need file path to continue, */
if ($type == \OCP\Files\FileInfo::TYPE_FOLDER) {
$query = [];
parse_str(parse_url($path, PHP_URL_QUERY), $query);
if (isset($query['path']) && isset($query['files'])) {
$node = $node->get($query['path'])->get($query['files']);
} else {
throw new NotFoundException('Shared file path or name not set');
}
}
$filePath = $node->getPath();
$fileId = $node->getId();
} else {
$filePath = $path;
$fileId = $this->rootFolder->getUserFolder($this->userId)
->get(preg_replace("/.*\/remote.php\/webdav(.*)/", "$1", rawurldecode($this->request->get['file'])))
->getFileInfo()
->getId();
}
return [
'fileName' => pathInfo($filePath, PATHINFO_FILENAME),
'fileType' => strtolower(pathInfo($filePath, PATHINFO_EXTENSION)),
'fileId' => $fileId
];
}
private function toJson($value) {
return htmlspecialchars(json_encode($value), ENT_QUOTES, 'UTF-8');
}
} `
Please help
Greets
on Nextcloud 11.
Steps: Share a folder with epub, open chrome incognito go to the public share folder. Open Epub
Expected:
Ebook is opened with the Ebook reader OR Ebook is downloaded normally
Receiving a
Finding this in javascript console on the file_readers