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

Do not inject window.Buffer #637

Closed
BlackGlory opened this issue Dec 11, 2018 · 2 comments · Fixed by #777
Closed

Do not inject window.Buffer #637

BlackGlory opened this issue Dec 11, 2018 · 2 comments · Fixed by #777
Labels
area/window-ipfs Issues related to IPFS API exposed on every page status/deferred Conscious decision to pause or backlog status/ready Ready to be worked

Comments

@BlackGlory
Copy link

I found that some websites such as zhihu.com will use window.Buffer, Buffer injected by ipfs-companion would break the normal behavior of these websites. Buffer can be set elsewhere.

https://github.com/ipfs-shipyard/ipfs-companion/blob/50db9c08d5bf0e5297981ff474da07585aa8a8ce/add-on/src/contentScripts/ipfs-proxy/page.js#L6

@lidel lidel added area/window-ipfs Issues related to IPFS API exposed on every page status/ready Ready to be worked status/deferred Conscious decision to pause or backlog labels Dec 13, 2018
@lidel lidel added this to the window.ipfs 2.0 milestone Dec 13, 2018
@lidel
Copy link
Member

lidel commented Dec 13, 2018

@BlackGlory Thank you for reporting this. Could you elaborate how it "break the normal behavior" of zhihu.com?

At the first glance I don't think the website will actually be broken: if window.Buffer already exists it will be left alone. You just won't be able to use Buffer implementation from ipfs-ompanion.

That being said, we are planning to stop injecting Buffer and to support ArrayBuffer as input argument in web browser contexts: ipfs-inactive/interface-js-ipfs-core#404

@BlackGlory
Copy link
Author

@lidel
Zhihu is a Chinese website, and triggering this abnormal behavior requires login, so it is quite difficult to explain. After enabling the extension, clicking on the "follow" button on the website will pop up an alert notice the operation failed. If window.Buffer is undefined, this alert will not appear.

According to my guess, there is an outdated fallback code inside the website that will detect window.Buffer, and its priority is higher than ArrayBuffer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/window-ipfs Issues related to IPFS API exposed on every page status/deferred Conscious decision to pause or backlog status/ready Ready to be worked
Projects
None yet
2 participants