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

I have bug in base64Source decode #5

Open
mason276752 opened this issue May 10, 2019 · 1 comment
Open

I have bug in base64Source decode #5

mason276752 opened this issue May 10, 2019 · 1 comment

Comments

@mason276752
Copy link

I "encode" that

// get iframe
var Base64 = require('js-base64').Base64;
var code = Base64.encode(
`console.log(1)
`)

var iframe = `<iframe src="https://runkit.com/e?base64source=${code}" frameborder="0" style="width: 100%;"></iframe>`
var textarea = iframe + "<textarea>" + iframe + "</textarea>"

It's Base64 code is

Ly8gZ2V0IGlmcmFtZQp2YXIgQmFzZTY0ID0gcmVxdWlyZSgnanMtYmFzZTY0JykuQmFzZTY0Owp2YXIgY29kZSA9IEJhc2U2NC5lbmNvZGUoCmBjb25zb2xlLmxvZygxKQpgKQoKdmFyIGlmcmFtZSA9IGA8aWZyYW1lIHNyYz0iaHR0cHM6Ly9ydW5raXQuY29tL2U/YmFzZTY0c291cmNlPSR7Y29kZX0iIGZyYW1lYm9yZGVyPSIwIiBzdHlsZT0id2lkdGg6IDEwMCU7Ij48L2lmcmFtZT5gCnZhciB0ZXh0YXJlYSA9IGlmcmFtZSArICI8dGV4dGFyZWE+IiArIGlmcmFtZSArICI8L3RleHRhcmVhPiI=

Now
We can put base64 code in <iframe>

<iframe src="https://runkit.com/e?base64source=Ly8gZ2V0IGlmcmFtZQp2YXIgQmFzZTY0ID0gcmVxdWlyZSgnanMtYmFzZTY0JykuQmFzZTY0Owp2YXIgY29kZSA9IEJhc2U2NC5lbmNvZGUoCmBjb25zb2xlLmxvZygxKQpgKQoKdmFyIGlmcmFtZSA9IGA8aWZyYW1lIHNyYz0iaHR0cHM6Ly9ydW5raXQuY29tL2U/YmFzZTY0c291cmNlPSR7Y29kZX0iIGZyYW1lYm9yZGVyPSIwIiBzdHlsZT0id2lkdGg6IDEwMCU7Ij48L2lmcmFtZT5gCnZhciB0ZXh0YXJlYSA9IGlmcmFtZSArICI8dGV4dGFyZWE+IiArIGlmcmFtZSArICI8L3RleHRhcmVhPiI=" frameborder="0" style="width: 100%;"></iframe>

Boom!! What is happen?
image

We can check the base64 code
image
look it is so good, no problem.

But, It put "https://runkit.com/e?base64source=" not good.

@mason276752
Copy link
Author

Base64 code have '+' or '=' symbol, use encodeURIComponent(code) fix the problem.

Help me close the issue. Thx

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

No branches or pull requests

1 participant