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

Minified builds do not work in some circumstances #1017

Closed
richard-fairthorne opened this issue Feb 12, 2018 · 12 comments
Closed

Minified builds do not work in some circumstances #1017

richard-fairthorne opened this issue Feb 12, 2018 · 12 comments
Labels

Comments

@richard-fairthorne
Copy link
Contributor

Minified builds found on CDN's do not work. They produce errors related to emojione.

example

<html>
<head>
  <link rel="stylesheet" type="text/css" media="screen" href="https://cdn.conversejs.org/3.3.2/css/converse.min.css">
  <script src="https://cdn.conversejs.org/3.3.2/dist/converse.min.js"></script>
</head>
<body>
  <script>
      converse.initialize({
          bosh_service_url: 'https://conversejs.org/http-bind/', // Please use this connection manager only for testing purposes
          show_controlbox_by_default: true
      });
  </script>
</body>
</html>

result in chrome

converse.min.js:sourcemap:293 Uncaught SyntaxError: Invalid regular expression: /<object[^>]*>.*?</object>|<span[^>]*>.*?</span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|(?:�)�?�?(?:🌈)|(?:�)�?�?(?:🗨)�?|[#-9]�?⃣|(?:(?:�)(?:�[�-�]){1,6})|(?:�[�-�]){2}|(?:(?:�[��]))�?(?:�[�-�])?�?(?:[⚕⚖✈]|�[�-�]|�[������])|(?:�[��]|�[�-�])(?:�[�-�])?�?[♀♂⚕⚖✈]?�?|(?:(?:�|�[�-��])[��]{0,2}){1,3}(?:�|�[�-��])|(?:(?:�|�[�-��])�?){2,4}|(?:�[����-���-�]|�[��]|�[�-�]|�[�-�]|�[�-�]|⛹|👯)�?(?:�[�-�])?�?[♀♂]?�?|(?:[�⛹✊-�]|�[�-�]|�[�-��-��-��-�]|�[�-�])�?(?:�[�-�])|(?:[↔-↙↩-↪]�?|[#*]|[〰〽]�?|(?:�[�-�]|🆎|�[�-�])�?|Ⓜ�?|[㊗㊙]�?|(?:�[�-�]|🈚|🈯|�[�-�]|�[�-�])�?|[‼�]�?|[▪-▫▶◀◻-◾]�?|[©®]�?|[™ℹ]�?|🀄�?|[⬅-⬇⬛-⬜�⭕]�?|[⌚-⌛⌨��-��-�]�?|�|[⤴⤵]�?)|[✀-➿]�?|[�-�][�-�]�?|[☀-⛿]�?|[0-9]�/: Range out of order in character class
    at new RegExp (<anonymous>)
    at emojione (converse.min.js:sourcemap:293)
    at converse.min.js:sourcemap:293
    at converse.min.js:sourcemap:266
    at converse.min.js:sourcemap:266
emojione @ converse.min.js:sourcemap:293
(anonymous) @ converse.min.js:sourcemap:293
(anonymous) @ converse.min.js:sourcemap:266
(anonymous) @ converse.min.js:sourcemap:266

workaround

Do not use minified builds

suggested temporary fixes

ideal fix

  • report upstream to the minify vendor.

Hope that's enough data. I nearly gave up adopting this 2 hours after finding it, because it was hard for me to debug given lack of familiarity with the project.

@jcbrand
Copy link
Member

jcbrand commented Feb 14, 2018

The specific build you link to in your example, https://cdn.conversejs.org/3.3.2/dist/converse.min.js, works fine for me. In fact, it can be tested live here: https://conversejs.org/3.3.2/

So I'm a bit confused. Is that the actual build that's giving you problems, or are you using another build?

@richard-fairthorne
Copy link
Contributor Author

Thanks for the quick response. The example is the actual file that fails. Removing ".min" from the filenames fixes the issues. So, the problem appears to be the browser?

I'll check a various clients and report back. This error is from this client:

Google Chrome	63.0.3239.132 (Official Build) (64-bit)
Revision	2e6edcfee630baa3775f37cb11796b1603a64360-refs/branch-heads/3239@{#709}
OS	Mac OS X
JavaScript	V8 6.3.292.49
Flash	28.0.0.161 /Users/admin/Library/Application Support/Google/Chrome/PepperFlash/28.0.0.161/PepperFlashPlayer.plugin
User Agent	Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
Command Line	/Applications/Google Chrome.app/Contents/MacOS/Google Chrome --flag-switches-begin --flag-switches-end
Executable Path	/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Profile Path	/Users/admin/Library/Application Support/Google/Chrome/Profile 1
Variations	c134752e-b8b72c88
4c328cc8-3f4a17df
3095aa95-3f4a17df
47e5d3db-3d47f4f4
1210a805-ecd831c
b1edbc38-cf4f6ead
ba3f87da-45bda656
776de70c-eadfd437
79616653-3f4a17df
9e201a2b-6e3ce1c
68812885-4d2fac87
f347910c-3d47f4f4
4b61504a-d25ea691
9773d3bd-f23d1dea
8e3b2dc5-93702590
f79cb77b-3d47f4f4
4ea303a6-ecbb250e
3d7e3f6a-2eb01455
d92562a9-ca7d8d80
90bcbadc-3f4a17df
25fc488a-4d2fac87
1c2f7bbf-3f4a17df
58a025e3-c2b41702
1bced4a3-90fa85cd
b2f0086-93053e47
ef25c1eb-3f4a17df
494d8760-6843eff2
f47ae82a-86f22ee5
3ac60855-486e2a9c
f296190c-92bb99a9
4442aae2-6e597ede
ed1d377-e1cc0f14
75f0f0a0-e1cc0f14
e2b18481-6e597ede
e7e71889-4ad60575
94e68624-803f8fc4
f141d4bc-28ad44a
e9ce63c1-36ab09a2
da4aaa01-4d2fac87

@richard-fairthorne
Copy link
Contributor Author

Same issue in safari. Regex error in the js.map -- I'm scratching my head. I am inclined to think it's something situational on my end, but I haven't got a clue.

I'm serving the html file from a server on my local host. I'll deploy it into the wild and see what happens.

@richard-fairthorne
Copy link
Contributor Author

richard-fairthorne commented Feb 14, 2018

In Safari, the browser window shows this information:

screen shot 2018-02-13 at 10 02 12 pm

I'm not sure that this is entirely relevant. it only happens with safari, while the html file is being served from http://localhost.

@richard-fairthorne
Copy link
Contributor Author

richard-fairthorne commented Feb 14, 2018

https://hashbang.info/index_converse_min.html
https://hashbang.info/index_converse_norm.html

The minified one does not work for me, in any browser on my mac, although it works fine from your site.

The example is cut and paste from the documentation.

Your actual website works fine from my computer.

scratches head

root@prime:/var/www/hashbang.info# diff index_converse_norm.html index_converse_min.html
4,5c4,5
<   <link rel="stylesheet" type="text/css" media="screen" href="https://cdn.conversejs.org/3.3.2/css/converse.css">
<   <script src="https://cdn.conversejs.org/3.3.2/dist/converse.js"></script>
---
>   <link rel="stylesheet" type="text/css" media="screen" href="https://cdn.conversejs.org/3.3.2/css/converse.min.css">
>   <script src="https://cdn.conversejs.org/3.3.2/dist/converse.min.js"></script>

@jcbrand
Copy link
Member

jcbrand commented Feb 14, 2018

I tested your example code as-is yesterday before I replied and it worked for me.

Try to do a hard refresh of all CDN assets through the browser. Perhaps something is cached.

The bourbon error is something else, that's CSS. To fix that, remove ./css/converse.min.css and generate it again with make css/converse.min.css.

@richard-fairthorne richard-fairthorne changed the title Minified builds do not work Minified builds do not work in some circumstances Feb 14, 2018
@richard-fairthorne
Copy link
Contributor Author

richard-fairthorne commented Feb 14, 2018

I have never used firefox before. Just installed it. It exhibits the same issue.

I'm waiting on an ubuntu install to try it there.

@jcbrand
Copy link
Member

jcbrand commented Mar 2, 2018

@richard-fairthorne any update on this?

@Zash
Copy link
Contributor

Zash commented Mar 6, 2018

The error looks like something feed UTF-8 data into a parser expecting Latin1. There doesn't seem to be any encoding specified on the HTML data from those pages on hashbang.info, nor from the CDN. Possible cause? See if adding <meta charset=utf-8> appears to fix it.

@badfiles
Copy link
Contributor

badfiles commented Mar 7, 2018

I confirm this issue. <meta charset=utf-8> fixes running the minified version for me. I use another charset, and the minified version is somehow incompatible with mine.

@richard-fairthorne
Copy link
Contributor Author

I confirm the workaround that Zash and badfiles are using.

https://hashbang.info/index_converse_min_utf-8.html

It seems as though, for a wide variety of browsers on mac, it only works after setting the character set to UTF-8. Is this something that a BOM could solve? I had to find a temporary solution, but I'd love to switch back.

I'll see if I can find a fix that doesn't require possibly breaking changes to websites.

@richard-fairthorne
Copy link
Contributor Author

richard-fairthorne commented Mar 30, 2018

Easy peazy!

If the documentation were updated to include the following tag, or similar, the problem would be resolved:

<script charset='utf-8' src="https://cdn.conversejs.org/3.3.2/dist/converse.min.js">

This solution is based on Zash/badfiles, requires no code changes, and fixes the problem across all of my browsers.

https://hashbang.info/index_converse_min_utf-8_script.html

Thanks for your help everyone. I'm patching the documentation now, for your consideration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants