Skip to content

Commit

Permalink
Merge pull request #40756 from nextcloud/fix/encoded-source
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv committed Oct 4, 2023
2 parents cf6e9a1 + d591510 commit 3f72582
Show file tree
Hide file tree
Showing 88 changed files with 155 additions and 154 deletions.
10 changes: 5 additions & 5 deletions apps/files/js/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -1063,8 +1063,8 @@ OC.Uploader.prototype = _.extend({
data.textStatus = 'notenoughspace';
data.errorThrown = t('files',
'Not enough free space, you are uploading {size1} but only {size2} is left', {
'size1': OC.Util.humanFileSize(selection.totalBytes),
'size2': OC.Util.humanFileSize(freeSpace)
'size1': OC.Util.humanFileSize(selection.totalBytes, false, false),
'size2': OC.Util.humanFileSize(freeSpace, false, false)
});
}

Expand Down Expand Up @@ -1302,9 +1302,9 @@ OC.Uploader.prototype = _.extend({
}

self._setProgressBarText(h, h, t('files', '{loadedSize} of {totalSize} ({bitrate})' , {
loadedSize: OC.Util.humanFileSize(data.loaded),
totalSize: OC.Util.humanFileSize(total),
bitrate: OC.Util.humanFileSize(smoothBitrate / 8) + '/s'
loadedSize: OC.Util.humanFileSize(data.loaded, false, false),
totalSize: OC.Util.humanFileSize(total, false, false),
bitrate: OC.Util.humanFileSize(smoothBitrate / 8, false, false) + '/s'
}));
self._setProgressBarValue(progress);
self.trigger('progressall', e, data);
Expand Down
8 changes: 4 additions & 4 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,7 @@

// size column
if (typeof(fileData.size) !== 'undefined' && fileData.size >= 0) {
simpleSize = OC.Util.humanFileSize(parseInt(fileData.size, 10), true);
simpleSize = OC.Util.humanFileSize(parseInt(fileData.size, 10), true, false);
// rgb(118, 118, 118) / #767676
// min. color contrast for normal text on white background according to WCAG AA
sizeColor = Math.round(118-Math.pow((fileData.size/(1024*1024)), 2));
Expand Down Expand Up @@ -2609,7 +2609,7 @@
var oldSize = oldFile.data('size');
var newSize = oldSize + newFile.data('size');
oldFile.data('size', newSize);
oldFile.find('td.filesize').text(OC.Util.humanFileSize(newSize));
oldFile.find('td.filesize').text(OC.Util.humanFileSize(newSize, false, false));

self.remove(fileName);
}
Expand Down Expand Up @@ -2752,7 +2752,7 @@
var oldSize = oldFile.data('size');
var newSize = oldSize + newFile.data('size');
oldFile.data('size', newSize);
oldFile.find('td.filesize').text(OC.Util.humanFileSize(newSize));
oldFile.find('td.filesize').text(OC.Util.humanFileSize(newSize, false, false));
}
self.reload();
})
Expand Down Expand Up @@ -3463,7 +3463,7 @@
}
else {
this.$el.find('.selectedActions').removeClass('hidden');
this.$el.find('.column-size a>span:first').text(OC.Util.humanFileSize(summary.totalSize));
this.$el.find('.column-size a>span:first').text(OC.Util.humanFileSize(summary.totalSize, false, false));

var directoryInfo = n('files', '%n folder', '%n folders', summary.totalDirs);
var fileInfo = n('files', '%n file', '%n files', summary.totalFiles);
Expand Down
6 changes: 3 additions & 3 deletions apps/files/js/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
&& response.data.total !== undefined
&& response.data.used !== undefined
&& response.data.usedSpacePercent !== undefined) {
var humanUsed = OC.Util.humanFileSize(response.data.used, true);
var humanTotal = OC.Util.humanFileSize(response.data.total, true);
var humanUsed = OC.Util.humanFileSize(response.data.used, true, false);
var humanTotal = OC.Util.humanFileSize(response.data.total, true, false);
if (response.data.quota > 0) {
$('#quota').attr('title', t('files', '{used}%', {used: Math.round(response.data.usedSpacePercent)}));
$('#quota progress').val(response.data.usedSpacePercent);
Expand Down Expand Up @@ -425,7 +425,7 @@ var createDragShadow = function(event) {
.attr('data-file', elem.name)
.attr('data-origin', elem.origin);
newtr.append($('<td class="filename"></td>').text(elem.name).css('background-size', 32));
newtr.append($('<td class="size"></td>').text(OC.Util.humanFileSize(elem.size)));
newtr.append($('<td class="size"></td>').text(OC.Util.humanFileSize(elem.size, false, false)));
tbody.append(newtr);
if (elem.type === 'dir') {
newtr.find('td.filename')
Expand Down
4 changes: 2 additions & 2 deletions apps/files/js/filesummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
$dirInfo.html(n('files', '%n folder', '%n folders', this.summary.totalDirs));
$fileInfo.html(n('files', '%n file', '%n files', this.summary.totalFiles));
$hiddenInfo.html(' (' + n('files', 'including %n hidden', 'including %n hidden', this.summary.totalHidden) + ')');
var fileSize = this.summary.sumIsPending ? t('files', 'Pending') : OC.Util.humanFileSize(this.summary.totalSize);
var fileSize = this.summary.sumIsPending ? t('files', 'Pending') : OC.Util.humanFileSize(this.summary.totalSize, false, false);
this.$el.find('.filesize').html(fileSize);

// Show only what's necessary (may be hidden)
Expand Down Expand Up @@ -263,7 +263,7 @@
// don't show the filesize column, if filesize is NaN (e.g. in trashbin)
var fileSize = '';
if (!isNaN(summary.totalSize)) {
fileSize = summary.sumIsPending ? t('files', 'Pending') : OC.Util.humanFileSize(summary.totalSize);
fileSize = summary.sumIsPending ? t('files', 'Pending') : OC.Util.humanFileSize(summary.totalSize, false, false);
fileSize = '<td class="filesize">' + fileSize + '</td>';
}

Expand Down
2 changes: 1 addition & 1 deletion apps/files/js/mainfileinfodetailview.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
path: this.model.get('path'),
hasSize: this.model.has('size'),
sizeLabel: t('files', 'Size'),
size: OC.Util.humanFileSize(this.model.get('size'), true),
size: OC.Util.humanFileSize(this.model.get('size'), true, false),
altSize: n('files', '%n byte', '%n bytes', this.model.get('size')),
dateLabel: t('files', 'Modified'),
altDate: OC.Util.formatDate(this.model.get('mtime')),
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/actions/deleteAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const action = new FileAction({

async exec(node: Node) {
try {
await axios.delete(node.source)
await axios.delete(node.encodedSource)

// Let's delete even if it's moved to the trashbin
// since it has been removed from the current view
Expand Down
4 changes: 2 additions & 2 deletions apps/files/src/actions/moveOrCopyAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const handleCopyMoveNodeTo = async (node: Node, destination: Folder, meth
}

const relativePath = join(destination.path, node.basename)
const destinationUrl = generateRemoteUrl(`dav/files/${getCurrentUser()?.uid}${relativePath}`)
const destinationUrl = generateRemoteUrl(encodePath(`dav/files/${getCurrentUser()?.uid}${relativePath}`))
logger.debug(`${method} ${node.basename} to ${destinationUrl}`)

// Set loading state
Expand All @@ -97,7 +97,7 @@ export const handleCopyMoveNodeTo = async (node: Node, destination: Folder, meth
try {
await axios({
method: method === MoveCopyAction.COPY ? 'COPY' : 'MOVE',
url: encodeURI(node.source),
url: node.encodedSource,
headers: {
Destination: encodeURI(destinationUrl),
Overwrite: overwrite ? undefined : 'F',
Expand Down
7 changes: 4 additions & 3 deletions apps/files/src/components/FileEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ export default Vue.extend({
// Rename and move the file
async onRename() {
const oldName = this.source.basename
const oldSource = this.source.source
const oldEncodedSource = this.source.encodedSource
const newName = this.newName.trim?.() || ''
if (newName === '') {
showError(this.t('files', 'Name cannot be empty'))
Expand All @@ -870,12 +870,13 @@ export default Vue.extend({
// Update node
this.source.rename(newName)
logger.debug('Moving file to', { destination: this.source.encodedSource, oldEncodedSource })
try {
await axios({
method: 'MOVE',
url: oldSource,
url: oldEncodedSource,
headers: {
Destination: encodeURI(this.source.source),
Destination: this.source.encodedSource,
},
})
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/newMenu/newFolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const entry = {
async handler(context: Folder, content: Node[]) {
const contentNames = content.map((node: Node) => node.basename)
const name = getUniqueName(t('files', 'New folder'), contentNames)
const { fileid, source } = await createNewFolder(context.source, name)
const { fileid, source } = await createNewFolder(context.encodedSource, encodeURIComponent(name))

// Create the folder in the store
const folder = new Folder({
Expand Down
3 changes: 1 addition & 2 deletions apps/files/src/services/Files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { getCurrentUser } from '@nextcloud/auth'
import { getClient, rootPath } from './WebdavClient'
import { hashCode } from '../utils/hashUtils'
import logger from '../logger'
import { encodePath } from '@nextcloud/paths'

const client = getClient()

Expand All @@ -45,7 +44,7 @@ export const resultToNode = function(node: FileStat): File | Folder {
const permissions = davParsePermissions(props?.permissions)
const owner = getCurrentUser()?.uid as string

const source = generateRemoteUrl(encodePath('dav' + rootPath + node.filename))
const source = generateRemoteUrl('dav' + rootPath + node.filename)
const id = props?.fileid < 0
? hashCode(source)
: props?.fileid as number || 0
Expand Down
2 changes: 1 addition & 1 deletion apps/files_trashbin/src/actions/restoreAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ registerFileAction(new FileAction({
const destination = generateRemoteUrl(encodePath(`dav/trashbin/${getCurrentUser()?.uid}/restore/${node.basename}`))
await axios({
method: 'MOVE',
url: node.source,
url: node.encodedSource,
headers: {
destination,
},
Expand Down
2 changes: 1 addition & 1 deletion apps/files_trashbin/src/services/trashbin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const resultToNode = function(node: FileStat): File | Folder {

const nodeData = {
id: node.props?.fileid as number || 0,
source: generateRemoteUrl(encodePath('dav' + rootPath + node.filename)),
source: generateRemoteUrl('dav' + rootPath + node.filename),
// do not show the mtime column
// mtime: new Date(node.lastmod),
mime: node.mime as string,
Expand Down
4 changes: 2 additions & 2 deletions dist/5912-5912.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/5912-5912.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/comments-comments-app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/comments-comments-app.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/comments-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/comments-init.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-common.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-login.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-profile.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-profile.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-unified-search.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-unified-search.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/dav-settings-personal-availability.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dav-settings-personal-availability.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/federatedfilesharing-vue-settings-admin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/federatedfilesharing-vue-settings-admin.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/federatedfilesharing-vue-settings-personal.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/federatedfilesharing-vue-settings-personal.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-init.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-personal-settings.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-personal-settings.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-reference-files.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-reference-files.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-sidebar.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-sidebar.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_external-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_external-init.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_reminders-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_reminders-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_sharing-files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-files_sharing_tab.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_sharing-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-init.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_sharing-personal-settings.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-personal-settings.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_trashbin-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_trashbin-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_versions-files_versions.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_versions-files_versions.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-vue-settings-admin-basic-settings.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-admin-basic-settings.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 3f72582

Please sign in to comment.