mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-06 17:33:18 +00:00
fixup for i18n; avoid XSS
- fixup for PR#5256
This commit is contained in:
@@ -5,7 +5,6 @@ import { gettext, repoPasswordMinLength } from '../../utils/constants';
|
|||||||
import { Utils } from '../../utils/utils';
|
import { Utils } from '../../utils/utils';
|
||||||
import { seafileAPI } from '../../utils/seafile-api';
|
import { seafileAPI } from '../../utils/seafile-api';
|
||||||
import toaster from '../toast';
|
import toaster from '../toast';
|
||||||
import StyledTitle from '../styled-title';
|
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
repoID: PropTypes.string.isRequired,
|
repoID: PropTypes.string.isRequired,
|
||||||
@@ -100,7 +99,7 @@ class ChangeRepoPasswordDialog extends React.Component {
|
|||||||
<Modal isOpen={true} centered={true} style={{height: 'auto'}}>
|
<Modal isOpen={true} centered={true} style={{height: 'auto'}}>
|
||||||
<ModalHeader toggle={toggleDialog}>
|
<ModalHeader toggle={toggleDialog}>
|
||||||
<span>
|
<span>
|
||||||
{gettext("Change Password of Library")}{' '}<StyledTitle title={repoName} />
|
{Utils.generateDialogTitle(gettext('Change Password of Library {placeholder}'), repoName)}
|
||||||
</span>
|
</span>
|
||||||
</ModalHeader>
|
</ModalHeader>
|
||||||
<ModalBody>
|
<ModalBody>
|
||||||
|
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
|
|||||||
import { Modal, ModalHeader, ModalBody, TabContent, TabPane, Nav, NavItem, NavLink } from 'reactstrap';
|
import { Modal, ModalHeader, ModalBody, TabContent, TabPane, Nav, NavItem, NavLink } from 'reactstrap';
|
||||||
import { gettext } from '../../utils/constants';
|
import { gettext } from '../../utils/constants';
|
||||||
import { Utils } from '../../utils/utils';
|
import { Utils } from '../../utils/utils';
|
||||||
import StyledTitle from '../styled-title';
|
|
||||||
import LibSubFolderSetUserPermissionDialog from './lib-sub-folder-set-user-permission-dialog';
|
import LibSubFolderSetUserPermissionDialog from './lib-sub-folder-set-user-permission-dialog';
|
||||||
import LibSubFolderSetGroupPermissionDialog from './lib-sub-folder-set-group-permission-dialog';
|
import LibSubFolderSetGroupPermissionDialog from './lib-sub-folder-set-group-permission-dialog';
|
||||||
import '../../css/share-link-dialog.css';
|
import '../../css/share-link-dialog.css';
|
||||||
@@ -65,28 +64,13 @@ class LibSubFolderPermissionDialog extends React.Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderHeader = () => {
|
|
||||||
const { repoName, folderName } = this.props;
|
|
||||||
if (repoName) {
|
|
||||||
return (
|
|
||||||
<Fragment>
|
|
||||||
<StyledTitle title={repoName} />{gettext('Folder Permission')}
|
|
||||||
</Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<Fragment>
|
|
||||||
{gettext('Set')}{' '}<StyledTitle title={folderName} />{gettext('permission')}
|
|
||||||
</Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { repoName, folderName } = this.props;
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Modal isOpen={true} style={{maxWidth: '980px'}} className="share-dialog" toggle={this.props.toggleDialog}>
|
<Modal isOpen={true} style={{maxWidth: '980px'}} className="share-dialog" toggle={this.props.toggleDialog}>
|
||||||
<ModalHeader toggle={this.props.toggleDialog}>
|
<ModalHeader toggle={this.props.toggleDialog}>
|
||||||
{this.renderHeader()}
|
<span>{repoName ? Utils.generateDialogTitle(gettext('{placeholder} Folder Permission'), repoName) : Utils.generateDialogTitle(gettext('Set {placeholder}\'s permission'), folderName)}</span>
|
||||||
</ModalHeader>
|
</ModalHeader>
|
||||||
<ModalBody className="dialog-list-container share-dialog-content" role="tablist">
|
<ModalBody className="dialog-list-container share-dialog-content" role="tablist">
|
||||||
{this.renderContent()}
|
{this.renderContent()}
|
||||||
|
@@ -8,7 +8,6 @@ import { gettext, isPro } from '../../utils/constants';
|
|||||||
import { Utils } from '../../utils/utils';
|
import { Utils } from '../../utils/utils';
|
||||||
import toaster from '../toast';
|
import toaster from '../toast';
|
||||||
import UserSelect from '../user-select';
|
import UserSelect from '../user-select';
|
||||||
import StyledTitle from '../styled-title/index.js';
|
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
itemName: PropTypes.string.isRequired,
|
itemName: PropTypes.string.isRequired,
|
||||||
@@ -69,7 +68,7 @@ class TransferDialog extends React.Component {
|
|||||||
return (
|
return (
|
||||||
<Modal isOpen={true}>
|
<Modal isOpen={true}>
|
||||||
<ModalHeader toggle={this.props.toggleDialog}>
|
<ModalHeader toggle={this.props.toggleDialog}>
|
||||||
{gettext('Transfer Library')}{' '}<StyledTitle title={itemName} />
|
<span>{gettext('Transfer Library {library_name}').replace('{library_name}', itemName)}</span>
|
||||||
</ModalHeader>
|
</ModalHeader>
|
||||||
<ModalBody>
|
<ModalBody>
|
||||||
{this.state.transferToUser ?
|
{this.state.transferToUser ?
|
||||||
|
@@ -29,15 +29,11 @@ class UploadRemindDialog extends React.Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { fileName } = this.props.currentResumableFile;
|
const { fileName } = this.props.currentResumableFile;
|
||||||
const titlePrefix = gettext('Replace file');
|
|
||||||
return (
|
return (
|
||||||
<Modal isOpen={true} toggle={this.toggle}>
|
<Modal isOpen={true} toggle={this.toggle}>
|
||||||
<ModalHeader toggle={this.toggle} >
|
<ModalHeader toggle={this.toggle}>
|
||||||
<div>
|
<span>{gettext('Replace file {filename}?').replace('{filename}', fileName)}</span>
|
||||||
<span>{titlePrefix}{' '}</span>
|
</ModalHeader>
|
||||||
<span class="a-simulate">{fileName}?</span>
|
|
||||||
</div>
|
|
||||||
</ModalHeader>
|
|
||||||
<ModalBody>
|
<ModalBody>
|
||||||
<p>{gettext('A file with the same name already exists in this folder.')}</p>
|
<p>{gettext('A file with the same name already exists in this folder.')}</p>
|
||||||
<p>{gettext('Replacing it will overwrite its content.')}</p>
|
<p>{gettext('Replacing it will overwrite its content.')}</p>
|
||||||
|
@@ -1,26 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
const propTypes = {
|
|
||||||
title: PropTypes.string.isRequired,
|
|
||||||
className: PropTypes.string,
|
|
||||||
};
|
|
||||||
|
|
||||||
class StyledTitle extends React.Component {
|
|
||||||
|
|
||||||
static defaultProps = {
|
|
||||||
className: '',
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const { title } = this.props;
|
|
||||||
const className = `op-target ellipsis ellipsis-op-target ${className}`
|
|
||||||
return (
|
|
||||||
<span className={className}>{title}{' '}</span>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledTitle.propTypes = propTypes;
|
|
||||||
|
|
||||||
export default StyledTitle;
|
|
@@ -10,7 +10,6 @@ import ModalPortal from './components/modal-portal';
|
|||||||
import toaster from './components/toast';
|
import toaster from './components/toast';
|
||||||
import CommonToolbar from './components/toolbar/common-toolbar';
|
import CommonToolbar from './components/toolbar/common-toolbar';
|
||||||
import CleanTrash from './components/dialog/clean-trash';
|
import CleanTrash from './components/dialog/clean-trash';
|
||||||
import StyledTitle from './components/styled-title';
|
|
||||||
|
|
||||||
import './css/toolbar.css';
|
import './css/toolbar.css';
|
||||||
import './css/search.css';
|
import './css/search.css';
|
||||||
@@ -193,9 +192,7 @@ class RepoFolderTrash extends React.Component {
|
|||||||
<div className="flex-auto container-fluid pt-4 pb-6 o-auto">
|
<div className="flex-auto container-fluid pt-4 pb-6 o-auto">
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-md-10 offset-md-1">
|
<div className="col-md-10 offset-md-1">
|
||||||
<h2>
|
<h2>{Utils.generateDialogTitle(gettext('{placeholder} Trash'), repoFolderName)}</h2>
|
||||||
<StyledTitle title={repoFolderName} />{gettext('Trash')}
|
|
||||||
</h2>
|
|
||||||
<a href="#" className="go-back" title={gettext('Back')} onClick={this.goBack} role="button" role={gettext('Back')}>
|
<a href="#" className="go-back" title={gettext('Back')} onClick={this.goBack} role="button" role={gettext('Back')}>
|
||||||
<span className="fas fa-chevron-left"></span>
|
<span className="fas fa-chevron-left"></span>
|
||||||
</a>
|
</a>
|
||||||
|
@@ -11,7 +11,6 @@ import ModalPortal from './components/modal-portal';
|
|||||||
import CommonToolbar from './components/toolbar/common-toolbar';
|
import CommonToolbar from './components/toolbar/common-toolbar';
|
||||||
import CommitDetails from './components/dialog/commit-details';
|
import CommitDetails from './components/dialog/commit-details';
|
||||||
import UpdateRepoCommitLabels from './components/dialog/edit-repo-commit-labels';
|
import UpdateRepoCommitLabels from './components/dialog/edit-repo-commit-labels';
|
||||||
import StyledTitle from './components/styled-title';
|
|
||||||
|
|
||||||
import './css/toolbar.css';
|
import './css/toolbar.css';
|
||||||
import './css/search.css';
|
import './css/search.css';
|
||||||
@@ -105,9 +104,7 @@ class RepoHistory extends React.Component {
|
|||||||
<div className="flex-auto container-fluid pt-4 pb-6 o-auto">
|
<div className="flex-auto container-fluid pt-4 pb-6 o-auto">
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-md-10 offset-md-1">
|
<div className="col-md-10 offset-md-1">
|
||||||
<h2>
|
<h2>{Utils.generateDialogTitle(gettext('{placeholder} Modification History'), repoName)}</h2>
|
||||||
<StyledTitle title={repoName} />{gettext('Modification History')}
|
|
||||||
</h2>
|
|
||||||
<a href="#" className="go-back" title={gettext('Back')} onClick={this.goBack} role="button" aria-label={gettext('Back')}>
|
<a href="#" className="go-back" title={gettext('Back')} onClick={this.goBack} role="button" aria-label={gettext('Back')}>
|
||||||
<span className="fas fa-chevron-left"></span>
|
<span className="fas fa-chevron-left"></span>
|
||||||
</a>
|
</a>
|
||||||
|
@@ -9,7 +9,6 @@ import ModalPortal from './components/modal-portal';
|
|||||||
import toaster from './components/toast';
|
import toaster from './components/toast';
|
||||||
import CommonToolbar from './components/toolbar/common-toolbar';
|
import CommonToolbar from './components/toolbar/common-toolbar';
|
||||||
import ConfirmRestoreRepo from './components/dialog/confirm-restore-repo';
|
import ConfirmRestoreRepo from './components/dialog/confirm-restore-repo';
|
||||||
import StyledTitle from './components/styled-title';
|
|
||||||
|
|
||||||
import './css/toolbar.css';
|
import './css/toolbar.css';
|
||||||
import './css/search.css';
|
import './css/search.css';
|
||||||
@@ -141,8 +140,8 @@ class RepoSnapshot extends React.Component {
|
|||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-md-10 offset-md-1">
|
<div className="col-md-10 offset-md-1">
|
||||||
<h2>
|
<h2>
|
||||||
<StyledTitle title={repoName} />{gettext('Snapshot')}{' '}
|
<span>{Utils.generateDialogTitle(gettext('{placeholder} Snapshot'), repoName)}</span>
|
||||||
<span class="heading-commit-time">(${commitTime})</span>
|
<span className="heading-commit-time ml-1">({commitTime})</span>
|
||||||
</h2>
|
</h2>
|
||||||
<a href="#" className="go-back" title={gettext('Back')} role="button" aria-label={gettext('Back')} onClick={this.goBack}>
|
<a href="#" className="go-back" title={gettext('Back')} role="button" aria-label={gettext('Back')} onClick={this.goBack}>
|
||||||
<span className="fas fa-chevron-left"></span>
|
<span className="fas fa-chevron-left"></span>
|
||||||
|
@@ -231,6 +231,18 @@ export const Utils = {
|
|||||||
.innerHTML;
|
.innerHTML;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
generateDialogTitle: function(title, operationTarget) {
|
||||||
|
/*
|
||||||
|
* @param title: gettext('...{placeholder}...')
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
const targetStr = this.HTMLescape(operationTarget);
|
||||||
|
const str = `<span class="op-target ellipsis ellipsis-op-target" title=${targetStr}>${targetStr}</span>`;
|
||||||
|
return title.replace('{placeholder}', str);
|
||||||
|
*/
|
||||||
|
return title.replace('{placeholder}', operationTarget);
|
||||||
|
},
|
||||||
|
|
||||||
getFileName: function(filePath) {
|
getFileName: function(filePath) {
|
||||||
let lastIndex = filePath.lastIndexOf('/');
|
let lastIndex = filePath.lastIndexOf('/');
|
||||||
return filePath.slice(lastIndex+1);
|
return filePath.slice(lastIndex+1);
|
||||||
|
Reference in New Issue
Block a user