Skip to content

Commit

Permalink
Decoupled the fileId separator from the web frontend implementation a…
Browse files Browse the repository at this point in the history
…nd made it part of the configuration
  • Loading branch information
glpatcern committed Oct 12, 2022
1 parent cb6af97 commit 40be472
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/core/commoniface.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def retrieverevalock(rawlock):

def encodeinode(endpoint, inode):
'''Encodes a given endpoint and inode to be used as a safe WOPISrc: endpoint is assumed to already be URL safe.
Note that the separator is chosen to be `!` for compatibility with the ownCloud Web frontend.'''
Note that the separator is chosen to be `!` (similar to how the web frontend is implemented) to allow the inverse
operation, assuming that `endpoint` does not contain any `!` characters.'''
return endpoint + '!' + urlsafe_b64encode(inode.encode()).decode()


Expand Down
5 changes: 3 additions & 2 deletions src/core/wopiutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,10 @@ def generateWopiSrc(fileid, proxy=False):


def generateUrlFromTemplate(url, acctok):
'''One-liner to parse an URL template and return it with actualised placeholders. See also common.encodeinode()'''
'''One-liner to parse an URL template and return it with actualised placeholders. See also common.encodeinode().'''
return url.replace('<path>', url_quote_plus(acctok['filename'])). \
replace('<resId>', acctok['endpoint'] + '!' + acctok['fileid']). \
replace('<endpoint>', acctok['endpoint']). \
replace('<fileid>', acctok['fileid']). \
replace('<app>', acctok['appname'])


Expand Down
17 changes: 9 additions & 8 deletions wopiserver.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,20 @@ loghandler = file

# Optional URL to display a file sharing dialog. This enables
# a 'Share' button within the application. The URL may contain
# the `<path>`, `<resId>`, and `<app>` placeholders, which are
# dynamically replaced with actual values for the opened file.
#filesharingurl = https://your-efss-server.org/fileshare?filepath=<path>&app=<app>&resource=<resId>
# any of the `<path>`, `<endpoint>`, `<fileid>`, and `<app>`
# placeholders, which are dynamically replaced with actual values
# for the opened file.
#filesharingurl = https://your-efss-server.org/fileshare?filepath=<path>&app=<app>&fileId=<endpoint>!<fileid>

# URLs for the pages that embed the application in edit mode and
# preview mode. By default, the appediturl and appviewurl are used,
# but it is recommended to configure here a URL that displays apps
# within an iframe on your EFSS.
# Placeholders `<path>`, `<resId>`, and `<app>` are dynamically
# replaced similarly to the above. The suggested example reflects
# the ownCloud web implementation.
#hostediturl = https://your-efss-server.org/external/spaces<path>?app=<app>&fileId=<resId>
#hostviewurl = https://your-efss-server.org/external/spaces<path>?app=<app>&fileId=<resId>&viewmode=VIEW_MODE_PREVIEW
# Placeholders `<path>`, `<endpoint>`, `<fileid>`, and `<app>` are
# dynamically replaced similarly to the above. The suggested example
# reflects the ownCloud web implementation.
#hostediturl = https://your-efss-server.org/external/spaces<path>?app=<app>&fileId=<endpoint>!<fileid>
#hostviewurl = https://your-efss-server.org/external/spaces<path>?app=<app>&fileId=<endpoint>!<fileid>&viewmode=VIEW_MODE_PREVIEW

# Optional URL prefix for WebDAV access to the files. This enables
# a 'Edit in Desktop client' action on Windows-based clients
Expand Down

0 comments on commit 40be472

Please sign in to comment.