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

Encoding is not UTF-8 error #414

Closed
ardmn opened this issue Jan 7, 2018 · 15 comments · Fixed by #3813
Closed

Encoding is not UTF-8 error #414

ardmn opened this issue Jan 7, 2018 · 15 comments · Fixed by #3813

Comments

@ardmn
Copy link

ardmn commented Jan 7, 2018

[REQUIRED] Describe your environment

  • Operating System version: mac os
  • Firebase SDK version: 4.8.1
  • Firebase Product: database

[REQUIRED] Describe the problem

browser show error When I try add firebase.js to chrome extension:
Can't load file /../firebase.js ... . Encoding is not UTF-8.

I try convert it to utf-8 but browser show error anyway

Steps to reproduce:

  1. download firebase.js using https://www.gstatic.com/firebasejs/4.8.1/firebase.js
  2. add firebase.js to chrome extension package
  3. enable developer mode in chrome browser
  4. load extension to chrome browser
@ardmn
Copy link
Author

ardmn commented Jan 12, 2018

Only avalible solution what I find it is using backgrounf.html, wich load firebase.js (<script> tag) and with messaging betwin background and conten scripts.

But if u know how download firebase.js or how transform firebase.js in order to use the js file in chrome extension - please tell me

@barna-n
Copy link

barna-n commented Jan 27, 2018

Same problem...

@davemart-in
Copy link

Seeing the same thing...

@schmidt-sebastian schmidt-sebastian self-assigned this Feb 9, 2018
@winterlightning
Copy link

same problem

@davemart-in
Copy link

I found a work-around. It doesn't look pretty, but by recompiling the second library that is included in firebase.js with Google closure compiler I was able to make it work: https://pastebin.com/QPDqVimD

@falcondai
Copy link

falcondai commented Mar 26, 2018

Another workaround by avoiding to import firebase-auth.js https://stackoverflow.com/a/49496631/1121123. The issue is likely the same as pouchdb/pouchdb#5798 due to the minifier (and settings) used

@protonhs
Copy link

@davemart-in your solution's awesome ! it solves it perfectly! Thanks!

@davemart-in
Copy link

davemart-in commented Apr 13, 2018 via email

@winterlightning
Copy link

I think leaving firebase-auth.js out is the best solution. You can auth in the chrome background or in the frame that pops up when you click on the icon. You can use send message to pass the auth token somehow.

@aseire
Copy link

aseire commented May 30, 2018

@davemart-in Brilliant! it solves it perfectly! Thank You!

@jshcrowthe jshcrowthe assigned Feiyang1 and unassigned jshcrowthe Sep 14, 2018
@lukejacksonn
Copy link

So I don't know what this approach might break.. but I wasn't happy with recompiling or using background.html and sending messages. So I searched the source for \u and eventually you come across the character it is used in this snippet of code xb=/\uffff/.test("�"). If you remove all instances of this character so that the code reads xb=/\uffff/.test("") then the error no longer appears but everything seems to work as normal (database and auth at least).

@mikelehen
Copy link
Contributor

FWIW, my guess is that line is coming from auth's use of closure's json library... https://github.com/google/closure-library/blob/db35cf1524b36a50d021fb6cf47271687cc2ea33/closure/goog/json/json.js#L305

Not 100% sure why it triggers the UTF-8 error or if there's a workaround though.

@lukejacksonn
Copy link

Yes, I believe this is the check (unminified) that I referenced in the comment above. Reassuring to see that it probably won't have any adverse effects on other browsers. Although my removal of the .test('\uffff') for test('') means that the ternary always take the first branch.

Also, for the record, I never actually managed to auth from the content script in the end, there is no was to access chrome.identity.getAuthToken from a content script and that is how all the examples suggest it should be done.

@laocoi
Copy link

laocoi commented Jan 9, 2020

I have the same problem with PHP when I extract text from HTML string by substr function.
substr($meta, 0, 160);
Look everything is good with echo but when use print_r function, end of extracted string has a mark like this ��.

The solution for who has the same problem like me:
mb_substr($meta, 0, 160, "utf-8")

@jasan-s
Copy link

jasan-s commented Sep 12, 2020

Is recompiling still the best solution for this? I attempted to recompile firebase.js and the complier threw an error. I was able to recompile individual libs i.e auth, app, firestone. however I get the same error after replacing my node_modules code with the recompiled code

@firebase firebase locked and limited conversation to collaborators Oct 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.