Repository: decidim/decidim (Ruby)

Issue:
Fingerprint calculator inconsistent
### Describe the bug

Let's say you have a proposal with a body text (raw input): "I want more trees in the central park      :)" (notice the multiple spaces) and you click on the "Check fingerprint link", it will tell you it's possible to generate the SHA256 by yourself via a third party calculator. Now if you copy the given source from decidim and use the source in the SHA256 calculator (or any valid calculator), you will get a different code from what decidim gives you.

This is because Decidim strips extra spaces from raw input to present the text more clear, however the same logic isn't used in the fingerprint calculator provided by decidim, but the data which is used to generate the SHA256 is taken straight from the model (raw input).

So basically this: "I want more trees in the central park      :)", which is used to generate the SHA256

is this: "I want more trees in the central park :)" (1 space is left, only extras removed), in the proposal view / Check fingerprint link -source.

### To Reproduce

1. Go to / create a proposal with a body text with multiple spaces in a row.
2. In the single proposal view (show), click on the "Check fingerprint link" -link at the bottom.
3. Check the given SHA256 code generated by decidim at the top of the modal.
4. Copy the Source hash from the modal and visit the MD5 -calculator website given to you in the instruction text under the source hash.
5. In MD5calc.com check that the algoritm is set to SHA256 and copy the source from decidim to the "string to encode" -input field.
6. Click "Encode" and see that the SHA256 code generated by that website differs from Decidim's calculator

### Expected behavior

The SHA256 generated should be consistent no matter where you generate it. So Decidim should calculate it with the same source data that is presented in the "Check fingerprint link" -modal. Now whether it should be a backend solution to strip extra spaces when saving data to the database or just show the raw input in the fingerprint source and keep the stripped data presented elsewhere, that I'm not sure of and it probably needs to be discussed about.

### Screenshots

_No response_

### Stacktrace

_No response_

### Extra data

- Device: PC
- Device OS: Ubuntu 24
- Browser: Chrome
- Decidim Version: 0.28
- Decidim installation: Local


### Additional context

_No response_



Fix (patch):
diff --git a/decidim-core/app/packs/stylesheets/decidim/_modal_fingerprint.scss b/decidim-core/app/packs/stylesheets/decidim/_modal_fingerprint.scss
index f5487576daab1..b7e3f437e57f2 100644
--- a/decidim-core/app/packs/stylesheets/decidim/_modal_fingerprint.scss
+++ b/decidim-core/app/packs/stylesheets/decidim/_modal_fingerprint.scss
@@ -8,7 +8,7 @@
   }
 
   &__code {
-    @apply block max-h-24 overflow-auto border border-gray-3 bg-background p-2 break-all;
+    @apply block max-h-24 overflow-auto border border-gray-3 bg-background p-2 break-words whitespace-pre-wrap;
   }
 
   a {
diff --git a/decidim-proposals/spec/system/fingerprint_proposal_spec.rb b/decidim-proposals/spec/system/fingerprint_proposal_spec.rb
index 1351f008a69df..e37238cb801aa 100644
--- a/decidim-proposals/spec/system/fingerprint_proposal_spec.rb
+++ b/decidim-proposals/spec/system/fingerprint_proposal_spec.rb
@@ -10,4 +10,12 @@
   end
 
   include_examples "fingerprint"
+
+  context "when proposal body text has multiple spaces in a row" do
+    let!(:fingerprintable) do
+      create(:proposal, component:, body: "Body text with extra    space")
+    end
+
+    include_examples "consistent fingerprint"
+  end
 end