whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Ruby <ru...@apache.org>
Subject [whimsy.git] [1/1] Commit affb73e: asciize file name
Date Thu, 07 Jan 2016 14:02:14 GMT
Commit affb73eef7ec86a0177e37b6d4ff3966c9d8a058:
    asciize file name


Branch: refs/heads/secmail
Author: Sam Ruby <rubys@intertwingly.net>
Committer: Sam Ruby <rubys@intertwingly.net>
Pusher: rubys <rubys@apache.org>

------------------------------------------------------------
www/secmail/views/app.js.rb                                  | + 
www/secmail/views/asciize.js.rb                              | +++++++++++++ 
www/secmail/views/forms/icla.js.rb                           | + -
------------------------------------------------------------
53 changes: 52 additions, 1 deletions.
------------------------------------------------------------


diff --git a/www/secmail/views/app.js.rb b/www/secmail/views/app.js.rb
index fc30ea6..773cdef 100644
--- a/www/secmail/views/app.js.rb
+++ b/www/secmail/views/app.js.rb
@@ -1,3 +1,4 @@
+require_relative 'asciize'
 require_relative 'http'
 require_relative 'status'
 
diff --git a/www/secmail/views/asciize.js.rb b/www/secmail/views/asciize.js.rb
new file mode 100644
index 0000000..8648088
--- /dev/null
+++ b/www/secmail/views/asciize.js.rb
@@ -0,0 +1,50 @@
+# Map non-ASCII characters to lower case ASCII
+def asciize(name)
+  if name =~ /[^\x00-\x7F]/
+    # digraphs.  May be culturally sensitive
+    name.gsub! /\u00df/, 'ss'
+    name.gsub! /\u00e4|a\u0308/, 'ae'
+    name.gsub! /\u00e5|a\u030a/, 'aa'
+    name.gsub! /\u00e6/, 'ae'
+    name.gsub! /\u00f1|n\u0303/, 'ny'
+    name.gsub! /\u00f6|o\u0308/, 'oe'
+    name.gsub! /\u00fc|u\u0308/, 'ue'
+
+    # latin 1
+    name.gsub! /[\u00e0-\u00e5]/, 'a'
+    name.gsub! /\u00e7/, 'c'
+    name.gsub! /[\u00e8-\u00eb]/, 'e'
+    name.gsub! /[\u00ec-\u00ef]/, 'i'
+    name.gsub! /[\u00f2-\u00f6]|\u00f8/, 'o'
+    name.gsub! /[\u00f9-\u00fc]/, 'u'
+    name.gsub! /[\u00fd\u00ff]/, 'y'
+
+    # Latin Extended-A
+    name.gsub! /[\u0100-\u0105]/, 'a'
+    name.gsub! /[\u0106-\u010d]/, 'c'
+    name.gsub! /[\u010e-\u0111]/, 'd'
+    name.gsub! /[\u0112-\u011b]/, 'e'
+    name.gsub! /[\u011c-\u0123]/, 'g'
+    name.gsub! /[\u0124-\u0127]/, 'h'
+    name.gsub! /[\u0128-\u0131]/, 'i'
+    name.gsub! /[\u0132-\u0133]/, 'ij'
+    name.gsub! /[\u0134-\u0135]/, 'j'
+    name.gsub! /[\u0136-\u0138]/, 'k'
+    name.gsub! /[\u0139-\u0142]/, 'l'
+    name.gsub! /[\u0143-\u014b]/, 'n'
+    name.gsub! /[\u014C-\u0151]/, 'o'
+    name.gsub! /[\u0152-\u0153]/, 'oe'
+    name.gsub! /[\u0154-\u0159]/, 'r'
+    name.gsub! /[\u015a-\u0162]/, 's'
+    name.gsub! /[\u0162-\u0167]/, 't'
+    name.gsub! /[\u0168-\u0173]/, 'u'
+    name.gsub! /[\u0174-\u0175]/, 'w'
+    name.gsub! /[\u0176-\u0178]/, 'y'
+    name.gsub! /[\u0179-\u017e]/, 'z'
+
+    # denormalized diacritics
+    name.gsub! /[\u0300-\u036f]/, ''
+  end
+
+  return name
+end
diff --git a/www/secmail/views/forms/icla.js.rb b/www/secmail/views/forms/icla.js.rb
index e7551c0..963da1d 100644
--- a/www/secmail/views/forms/icla.js.rb
+++ b/www/secmail/views/forms/icla.js.rb
@@ -113,7 +113,7 @@ def componentDidUpdate()
 
   # generate file name from the public name
   def genfilename()
-    @filename ||= @pubname.downcase().gsub(/\W/, '-')
+    @filename ||= asciize(@pubname.strip()).downcase().gsub(/\W/, '-')
   end
 
   # handle ICLA form submission

Mime
View raw message