Robert Vogel has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/320780

Change subject: Non-ASCII characters handling. Replacing umlauts with 
transliterated values rather than removing them
......................................................................

Non-ASCII characters handling. Replacing umlauts with transliterated
values rather than removing them

Change-Id: Ida7af47a40d5b74685513362ce19038377cbf759
---
M InsertFile/resources/BS.InsertFile/UploadPanel.js
1 file changed, 21 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions 
refs/changes/80/320780/1

diff --git a/InsertFile/resources/BS.InsertFile/UploadPanel.js 
b/InsertFile/resources/BS.InsertFile/UploadPanel.js
index b640367..acd2727 100644
--- a/InsertFile/resources/BS.InsertFile/UploadPanel.js
+++ b/InsertFile/resources/BS.InsertFile/UploadPanel.js
@@ -37,7 +37,7 @@
                this.tfFileName = Ext.create('Ext.form.TextField', {
                        fieldLabel: 
mw.message('bs-insertfile-uploaddestfilelabel').plain(),
                        id: this.getId()+'-filename',
-                       maskRe: /[^\/\?\*\"\#\<\>\|\\]/,
+                       maskRe: 
/[^\/\?\*\"\#\<\>\|\ö\ä\ü\Ö\Ä\Ü\á\à\â\é\è\ê\ú\ù\û\ó\ò\ô\Á\À\Â\É\È\Ê\Ú\Ù\Û\Ó\Ò\Ô\ß\\]/,
                        name: 'filename'
                });
                this.tfFileName.on( 'change', this.tfFileNameChange, this );
@@ -157,7 +157,26 @@
                value = value.replace(/^.*?([^\\\/:]*?\.[a-z0-9]+)$/img, "$1");
                value = value.replace(/\s/g, "_");
                if( mw.config.get('bsIsWindows') ) {
-                       value = value.replace(/[^\u0000-\u007F]/gmi, ''); 
//Replace Non-ASCII
+                       //replace non-ASCII
+                       var matcher = /[öäüÖÄÜáàâéèêúùûóòôÁÀÂÉÈÊÚÙÛÓÒÔß]/g;
+                       var dictionary = {
+                                 "ä": "ae", "ö": "oe", "ü": "ue",
+                                 "Ä": "Ae", "Ö": "Oe", "Ü": "Ue",
+                                 "á": "a", "à": "a", "â": "a",
+                                 "é": "e", "è": "e", "ê": "e",
+                                 "ú": "u", "ù": "u", "û": "u",
+                                 "ó": "o", "ò": "o", "ô": "o",
+                                 "Á": "A", "À": "A", "Â": "A",
+                                 "É": "E", "È": "E", "Ê": "E",
+                                 "Ú": "U", "Ù": "U", "Û": "U",
+                                 "Ó": "O", "Ò": "O", "Ô": "O",
+                                 "ß": "ss"
+                               };
+                       var translator = function(match) {
+                                 return dictionary[match] || match;
+                       }
+                       value = value.replace(matcher, translator);
+                       value = value.replace(/[^\u0000-\u007F]/gmi, ''); 
//Replace remaining Non-ASCII
                }
 
                this.tfFileName.setValue(value);
@@ -201,7 +220,6 @@
        checkFileSize: function( ExtCmpId ) {
                //No FileAPI? No love.
                if(typeof window.FileReader === 'undefined') return true;
-
                var allowedSize = mw.config.get('bsMaxUploadSize');
                if( allowedSize === null ) return true;
 

-- 
To view, visit https://gerrit.wikimedia.org/r/320780
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ida7af47a40d5b74685513362ce19038377cbf759
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Robert Vogel <[email protected]>
Gerrit-Reviewer: ItSpiderman <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to