Browse Source

bugfix: signature computation was broken for multiline texts

master
Christian Mueller 12 years ago
parent
commit
144218ecc2
  1. 2
      API.md
  2. 4
      resources/public/js/main.js
  3. 2
      src/notehub/storage.clj

2
API.md

@ -85,6 +85,7 @@ The Signature is the MD5 hash of the following string concatenation: @@ -85,6 +85,7 @@ The Signature is the MD5 hash of the following string concatenation:
pid + psk + note
The signature serves as a proof, that the request is authentic and will be issued by the publisher corresponding to the provided PID. Please note, that _all_ of the values used in the signature computation, should be identical to the values passed with the request itself.
Ensure, that your note contains only `\\n` symbols as line breaks!
The parameters specifying the theme name and fonts are optional and only impact the URLs returned back.
@ -126,6 +127,7 @@ The Signature is the MD5 hash of the following string concatenation: @@ -126,6 +127,7 @@ The Signature is the MD5 hash of the following string concatenation:
pid + psk + noteID + note + password
Please note, that all of the values used in the signature computation, should be identical to the values passed with the request itself.
Ensure, that your note contains only `\\n` symbols as line breaks!
The response of the server will contain the fields `longURL`, `shortURL`, `status`.

4
resources/public/js/main.js

@ -5,9 +5,7 @@ var timerDelay = iosDetected ? 800 : 400; @@ -5,9 +5,7 @@ var timerDelay = iosDetected ? 800 : 400;
var show = function(elem) { elem.style.display = "block" }
var $note, $action, $preview, $plain_password, $input_elems, $dashed_line, updatePreview;
var md5 = function (input) {
return hex_md5(input.replace(/[\n\r]/g, ""));
}
var md5 = hex_md5;
function md2html(input){
return marked(input);

2
src/notehub/storage.clj

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
(defn sign
"Returns the MD5 hash for the concatenation of all passed parameters"
[& args]
(let [input (apply str args)]
(let [input (sreplace (apply str args) #"\r*" "")]
(do (.reset md5Instance)
(.update md5Instance (.getBytes input))
(apply str

Loading…
Cancel
Save