mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 09:55:20 -05:00
Don't allow files to be created with / or * characters
Requires the following translations: "files_cannot_include_invalid_characters": "Files cannot include '*' or '/' characters", "invalid_file_name": "Invalid File Name"
This commit is contained in:
parent
2478a95bcb
commit
4386ab1225
4 changed files with 41 additions and 3 deletions
|
@ -315,8 +315,12 @@ script(type='text/ng-template', id='newDocModalTemplate')
|
|||
required,
|
||||
ng-model="inputs.name",
|
||||
on-enter="create()",
|
||||
select-name-on="open"
|
||||
select-name-on="open",
|
||||
ng-pattern="validFileRegex",
|
||||
name="name"
|
||||
)
|
||||
.text-danger.row-spaced-small(ng-show="newDocForm.name.$error.pattern")
|
||||
| #{translate('files_cannot_include_invalid_characters')}
|
||||
.modal-footer
|
||||
button.btn.btn-default(
|
||||
ng-disabled="state.inflight"
|
||||
|
@ -341,8 +345,12 @@ script(type='text/ng-template', id='newFolderModalTemplate')
|
|||
required,
|
||||
ng-model="inputs.name",
|
||||
on-enter="create()",
|
||||
select-name-on="open"
|
||||
select-name-on="open",
|
||||
ng-pattern="validFileRegex",
|
||||
name="name"
|
||||
)
|
||||
.text-danger.row-spaced-small(ng-show="newFolderForm.name.$error.pattern")
|
||||
| #{translate('files_cannot_include_invalid_characters')}
|
||||
.modal-footer
|
||||
button.btn.btn-default(
|
||||
ng-disabled="state.inflight"
|
||||
|
@ -414,3 +422,13 @@ script(type='text/ng-template', id='deleteEntityModalTemplate')
|
|||
)
|
||||
span(ng-hide="state.inflight") #{translate("delete")}
|
||||
span(ng-show="state.inflight") #{translate("deleting")}...
|
||||
|
||||
script(type='text/ng-template', id='invalidFileNameModalTemplate')
|
||||
.modal-header
|
||||
h3 #{translate('invalid_file_name')}
|
||||
.modal-body
|
||||
p #{translate('files_cannot_include_invalid_characters')}
|
||||
.modal-footer
|
||||
button.btn.btn-default(
|
||||
ng-click="$close()"
|
||||
) #{translate('ok')}
|
|
@ -88,6 +88,8 @@ define [
|
|||
|
||||
window._ide = ide
|
||||
|
||||
ide.validFileRegex = '^[^\*\/]*$' # Don't allow * and /
|
||||
|
||||
ide.project_id = $scope.project_id = window.project_id
|
||||
ide.$scope = $scope
|
||||
|
||||
|
|
|
@ -44,6 +44,8 @@ define [
|
|||
App.controller "NewDocModalController", [
|
||||
"$scope", "ide", "$modalInstance", "$timeout", "parent_folder",
|
||||
($scope, ide, $modalInstance, $timeout, parent_folder) ->
|
||||
$scope.validFileRegex = ide.validFileRegex
|
||||
|
||||
$scope.inputs =
|
||||
name: "name.tex"
|
||||
$scope.state =
|
||||
|
@ -74,6 +76,8 @@ define [
|
|||
App.controller "NewFolderModalController", [
|
||||
"$scope", "ide", "$modalInstance", "$timeout", "parent_folder",
|
||||
($scope, ide, $modalInstance, $timeout, parent_folder) ->
|
||||
$scope.validFileRegex = ide.validFileRegex
|
||||
|
||||
$scope.inputs =
|
||||
name: "name"
|
||||
$scope.state =
|
||||
|
|
|
@ -26,9 +26,23 @@ define [
|
|||
$scope.startRenaming = () ->
|
||||
$scope.entity.renaming = true
|
||||
|
||||
invalidModalShowing = false
|
||||
$scope.finishRenaming = () ->
|
||||
delete $scope.entity.renaming
|
||||
name = $scope.inputs.name
|
||||
|
||||
if !name.match(/^[^\*\/]*$/)
|
||||
# Showing the modal blurs the rename box which calls us again
|
||||
# so track this with the invalidModalShowing flag
|
||||
return if invalidModalShowing
|
||||
invalidModalShowing = true
|
||||
modal = $modal.open(
|
||||
templateUrl: "invalidFileNameModalTemplate"
|
||||
)
|
||||
modal.result.then () ->
|
||||
invalidModalShowing = false
|
||||
return
|
||||
|
||||
delete $scope.entity.renaming
|
||||
if !name? or name.length == 0
|
||||
$scope.inputs.name = $scope.entity.name
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue