pcibraro / hawknet

Hawk protocol implementation for .NET
MIT License
114 stars 35 forks source link

normalized string formatting in CalculateMac() #10

Closed TeigeJDavidson closed 10 years ago

TeigeJDavidson commented 11 years ago

re: CalculateMac() method please look at the normalized string. i believe this is a more consistent formatting of it

//old lines in question //((!string.IsNullOrEmpty(ext)) ? ext : "") + "\n"; // compared to java - escaped newline //((!string.IsNullOrEmpty(payloadHash)) ? payloadHash + "\n" : "") + //compared to java version - add \n always after

//proposed string for normalized var

        var normalized = "hawk.1." + type + "\n" +
                    ts + "\n" +
                    nonce + "\n" +
                    method.ToUpper() + "\n" +
                    uri.PathAndQuery + "\n" +
                    host.ToLower() + "\n" +
                    uri.Port.ToString() + "\n" +
                    ((!string.IsNullOrEmpty(payloadHash)) ? payloadHash : "") + "\n" +
                    ((!string.IsNullOrEmpty(ext)) ? ext.Replace("\\", "\\\\").Replace("\n", "\\n") : "") + "\n";