Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compress Bug report #3321

Closed
weifeihaung opened this issue Jan 31, 2019 · 0 comments · Fixed by #3329
Closed

Compress Bug report #3321

weifeihaung opened this issue Jan 31, 2019 · 0 comments · Fixed by #3329

Comments

@weifeihaung
Copy link

weifeihaung commented Jan 31, 2019

Bug report or feature request?

Uglify version (uglifyjs -V)
3.4.9
JavaScript input

utf8.write = function utf8_write(string, buffer, offset) {
    var start = offset,
        c1, // character 1
        c2; // character 2
    for (var i = 0; i < string.length; ++i) {
        c1 = string.charCodeAt(i);
        if (c1 < 128) {
            buffer[offset++] = c1;
        } else if (c1 < 2048) {
            buffer[offset++] = c1 >> 6       | 192;
            buffer[offset++] = c1       & 63 | 128;
        } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
            c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
            ++i;
            buffer[offset++] = c1 >> 18      | 240;
            buffer[offset++] = c1 >> 12 & 63 | 128;
            buffer[offset++] = c1 >> 6  & 63 | 128;
            buffer[offset++] = c1       & 63 | 128;
        } else {
            buffer[offset++] = c1 >> 12      | 224;
            buffer[offset++] = c1 >> 6  & 63 | 128;
            buffer[offset++] = c1       & 63 | 128;
        }
    }
    return offset - start;
};

The uglifyjs CLI command executed or minify() options used.
uglifyjs utf8_write.js -c -m -b -o utf8_write.min.js
JavaScript output or error produced.

utf8.write = function(r, t, e) {
    for (var n, o, a = e, c = 0; c < r.length; ++c) 
    n = r.charCodeAt(c), 
    t[e++] = n < 128 ? n : (t[e++] = n < 2048 ? n >> 6 | 192 : (55296 == (64512 & n) && 56320 == (64512 & (o = r.charCodeAt(c + 1))) ? (n = 65536 + ((1023 & n) << 10) + (1023 & o), 
    ++c, t[e++] = n >> 18 | 240, t[e++] = n >> 12 & 63 | 128) : t[e++] = n >> 12 | 224, 
    n >> 6 & 63 | 128), 63 & n | 128);
    return e - a;
};

project.zip

alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Mar 12, 2019
alexlamsl added a commit that referenced this issue Mar 12, 2019
fixes #3245
fixes #3257
fixes #3260
fixes #3269
fixes #3271
fixes #3278
fixes #3309
fixes #3319
fixes #3321
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant