Giter Site home page Giter Site logo

Comments (3)

scollon42 avatar scollon42 commented on July 20, 2024

Seems that

function decodeQuotedPrintableHelper

return NaN for the last prefix = after Merci.
and when the result go to

function convertBytesToUnicodeCodePoints

it will duplicate the previous bytes while where there is a NaN
for exemple

var ret = decodeQuotedPrintableHelper("BLACKLISTED WAKE UP SMS SENT (+33612345678) : Votre code de v=C3=A9rifica=tion Koolicar : 140035=", "=")

ret /*=> [66, 76, 65, 67, 75, 76, 73, 83, 84, 69, 68, 32, 87, 65, 75, 69, 32, 85, 80, 32, 83, 77, 83, 32, 83, 69, 78, 84, 32, 40, 43, 51, 51, 54, 49, 50, 51, 52, 53, 54, 55, 56, 41, 32, 58, 32, 86, 111, 116, 114, 101, 32, 99, 111, 100, 101, 32, 100, 101, 32, 118, 195, 169, 114, 105, 102, 105, 99, 97, NaN, 111, 110, 32, 75, 111, 111, 108, 105, 99, 97, 114, 32, 58, 32, 49, 52, 48, 48, 51, 53, NaN] */

convertBytesToUnicodeCodePoints(ret, "UTF8") /*=> [66, 76, 65, 67, 75, 76, 73, 83, 84, 69, 68, 32, 87, 65, 75, 69, 32, 85, 80, 32, 83, 77, 83, 32, 83, 69, 78, 84, 32, 40, 43, 51, 51, 54, 49, 50, 51, 52, 53, 54, 55, 56, 41, 32, 58, 32, 86, 111, 116, 114, 101, 32, 99, 111, 100, 101, 32, 100, 101, 32, 118, 233, 114, 105, 102, 105, 99, 97, 97, 111, 110, 32, 75, 111, 111, 108, 105, 99, 97, 114, 32, 58, 32, 49, 52, 48, 48, 51, 53, 53] */

I think for this last char in decodeQuotedPrintableHelper function there is an edge case.
here prefix for quoted printable is = the function will go through this condition :

if (str.charAt(i) == prefix ) {
  ret= decoded_bytes.push(parseInt(str.substr(i + 1, 2), 16));
  i += 3;
}

but here :

parseInt(str.substr(i + 1, 2), 16)
/* i + 1 == str.length  so str.substr will return an empty string and parseInt will return NaN */

This can fix the NaN case :

function decodeQuotedPrintableHelper(str, prefix) {
  var decoded_bytes = [];
  for (var i = 0; i < str.length;) {
    if (str.charAt(i) == prefix) {

     // here we check if it's not the end of the str
      if (i + 1 < str.length) {
      	decoded_bytes.push(parseInt(str.substr(i + 1, 2), 16));
      }

      i += 3;
    } else {
      decoded_bytes.push(str.charCodeAt(i));
	  ++i;
    }
  }
  return decoded_bytes;
}

hope this can help 😃

from mailhog-ui.

scollon42 avatar scollon42 commented on July 20, 2024

it should be fixed by this Pull Request: #33
I did a quick fix so don't hesitate to challenge it and review the code 😄

from mailhog-ui.

TheMatrix97 avatar TheMatrix97 commented on July 20, 2024

I have the same issue, using encoding cp1252.
plain text: "enlla seggent"
Source code: "l'enlla=E7 seg=FCent"
@scollon42 How could I include this modification to a running docker container?

from mailhog-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.