Comments (3)
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.
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.
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)
- Focus button in deleteAll modal HOT 2
- Case insensitive Content-Type not handled as html HOT 5
- Web interface broken in MacOS Chrome HOT 2
- Relaese message does nothing HOT 6
- How are messages sorted? HOT 2
- Consider using ng-cloak to prevent placeholders from being shown on page load HOT 2
- Hide jim message HOT 5
- wrong decode with quoted-printable
- Travis CI build failing
- Upgrade jQuery HOT 1
- Update moment.js - v2.8.4 - CVE-2017-18214
- Travis CI build is failing. HOT 1
- Mail list shows `{{ getSender(message) }}` when mail doesn't have a `From:` header HOT 4
- show preheaders in WEB UI
- Incorrect rendering for multipart/related with RFC compliant headers HOT 1
- Missing charset leads to error in the frontend
- Add Dark Mode Support HOT 1
- Flag to set webpath
- Headers should not be case sensitive HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mailhog-ui.