]> git.openstreetmap.org Git - rails.git/commitdiff
Use the URL safe base64 variant for mail tokens
authorTom Hughes <tom@compton.nu>
Wed, 8 Nov 2023 22:53:18 +0000 (22:53 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 8 Nov 2023 22:53:18 +0000 (22:53 +0000)
app/models/diary_comment.rb
app/models/message.rb

index 8663212ebeef93a38dbd0ce7399f09e975ebfb04..55d2c3c84af76790de21916109eb0bacc31199a8 100644 (file)
@@ -42,7 +42,7 @@ class DiaryComment < ApplicationRecord
     sha256 << Rails.application.key_generator.generate_key("openstreetmap/diary_comment")
     sha256 << id.to_s
     sha256 << subscriber.to_s
-    sha256.base64digest[0, 8]
+    Base64.urlsafe_encode64(sha256.digest)[0, 8]
   end
 
   private
index 0068bc3de504ee2d7e380cc2641b4ae1889082ba..7c12769d3a3e39f081caeb16dd0417a858a0ddc2 100644 (file)
@@ -63,6 +63,6 @@ class Message < ApplicationRecord
     sha256 = Digest::SHA256.new
     sha256 << Rails.application.key_generator.generate_key("openstreetmap/message")
     sha256 << id.to_s
-    sha256.base64digest[0, 8]
+    Base64.urlsafe_encode64(sha256.digest)[0, 8]
   end
 end