Browse Source

Check if file is a symlink with web editor (#3687)

* editor checks for symlinks

* translate file_is_a_symlink message

* credit translation author
Stefan Grönke 8 years ago
parent
commit
3376354ed8

+ 1 - 0
conf/locale/TRANSLATORS

@@ -17,6 +17,7 @@ Barış Arda Yılmaz <ardayilmazgamer AT gmail DOT com>
 Camille Baronnet <gogs AT camillebaronnet DOT fr>
 Christoph Kisfeld <christoph DOT kisfeld AT gmail DOT com>
 Cysioland
+Damaris Padieu <damizx AT hotmail DOT fr>
 Daniel Speichert <daniel AT speichert DOT pl>
 David Yzaguirre <dvdyzag AT gmail DOT com>
 Dmitriy Nogay <me AT catwhocode DOT ga>

+ 1 - 0
conf/locale/locale_de-DE.ini

@@ -455,6 +455,7 @@ editor.cancel=Abbrechen
 editor.filename_cannot_be_empty=Der Dateiname darf nicht leer sein.
 editor.branch_already_exists=Branch '%s' existiert bereits in diesem Repository.
 editor.directory_is_a_file='%s' im übergeordneten Verzeichnis ist eine Datei und kein Verzeichnis.
+editor.file_is_a_symlink=Die Datei '%s' ist ein Symlink der nicht über den Web Editor bearbeitet werden kann.
 editor.filename_is_a_directory=Die Datei '%s' existiert bereits als Verzeichnis in diesem Repository.
 editor.file_editing_no_longer_exists=Die Datei '%s', welche Sie bearbeiten, existiert in diesem Repository nicht mehr.
 editor.file_changed_while_editing=Seit dem Start der Bearbeitung hat sich die Datei geändert. <a target="_blank" href="%s">Hier klicken</a> um die Änderungen zu sehen, oder nochmals <strong>Commit drücken</strong> um die Änderungen zu überschreiben.

+ 1 - 0
conf/locale/locale_en-US.ini

@@ -457,6 +457,7 @@ editor.cancel = Cancel
 editor.filename_cannot_be_empty = Filename cannot be empty.
 editor.branch_already_exists = Branch '%s' already exists in this repository.
 editor.directory_is_a_file = Entry '%s' in the parent path is a file not a directory in this repository.
+editor.file_is_a_symlink = The file '%s' is a symlink that cannot be modified from the web editor
 editor.filename_is_a_directory = The filename '%s' is an existing directory in this repository.
 editor.file_editing_no_longer_exists = The file '%s' you are editing no longer exists in the repository.
 editor.file_changed_while_editing = File content has been changed since you started editing. <a target="_blank" href="%s">Click here</a> to see what have been changed or <strong>press commit again</strong> to overwrite those changes.

+ 1 - 0
conf/locale/locale_fr-FR.ini

@@ -455,6 +455,7 @@ editor.cancel=Annuler
 editor.filename_cannot_be_empty=Nom de fichier ne peut pas être vide.
 editor.branch_already_exists=La branche '%s' existe déjà dans ce dépôt.
 editor.directory_is_a_file=L'entrée '%s' dans le chemin d’accès parent est un fichier pas un répertoire dans ce dépôt.
+editor.file_is_a_symlink=Le fichier '%s' est un lien symbolique qui ne peut pas être modifié par l'éditeur web
 editor.filename_is_a_directory=Le nom de fichier '%s' existe déjà dans ce dépot.
 editor.file_editing_no_longer_exists=Le fichier '%s' que vous modifiez n'existe plus dans le dépôt.
 editor.file_changed_while_editing=Le contenu du fichier à changé depuis que vous avez commencé à l'éditer. <a target="_blank" href="%s">Cliquez ici</a> pour voir ce qui à été modifié ou <strong>appuyez sur commit encore une fois</strong> pour remplacer ces changements.

+ 1 - 0
conf/locale/locale_zh-CN.ini

@@ -455,6 +455,7 @@ editor.cancel=取消
 editor.filename_cannot_be_empty=文件名不能为空。
 editor.branch_already_exists=此仓库已存在名为 '%s' 的分支。
 editor.directory_is_a_file=路径 '%s' 的父路径中包含此仓库已存在的文件名。
+editor.file_is_a_symlink = '%s'数据是网页编辑器不能改变的符号链接。
 editor.filename_is_a_directory=文件名 '%s' 是此仓库中已存在的目录名。
 editor.file_editing_no_longer_exists=您编辑的文件 '%s' 已经不存在于此仓库中。
 editor.file_changed_while_editing=文件内容在您进行编辑时已经发生变动。<a target="_blank" href="%s">单击此处</a> 查看变动的具体内容,或者 <strong>再次提交</strong> 覆盖已发生的变动。

+ 5 - 0
routers/repo/editor.go

@@ -184,6 +184,11 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
 				return
 			}
 		} else {
+			if entry.IsLink() {
+				ctx.Data["Err_TreePath"] = true
+				ctx.RenderWithErr(ctx.Tr("repo.editor.file_is_a_symlink", part), EDIT_FILE, &form)
+				return
+			}
 			if entry.IsDir() {
 				ctx.Data["Err_TreePath"] = true
 				ctx.RenderWithErr(ctx.Tr("repo.editor.filename_is_a_directory", part), EDIT_FILE, &form)