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

note plugin: Unexpected token o in JSON at position 1 #3154

Closed
Mister-Hope opened this issue Mar 14, 2022 · 3 comments
Closed

note plugin: Unexpected token o in JSON at position 1 #3154

Mister-Hope opened this issue Mar 14, 2022 · 3 comments

Comments

@Mister-Hope
Copy link
Contributor

Mister-Hope commented Mar 14, 2022

// Keep listening for speaker view hearbeats. If we receive a
// heartbeat from an orphaned window, reconnect it. This ensures
// that we remain connected to the notes even if the presentation
// is reloaded.
window.addEventListener( 'message', event => {
if( !speakerWindow ) {
let data = JSON.parse( event.data );
if( data && data.namespace === 'reveal-notes' && data.type === 'heartbeat' ) {
reconnectSpeakerWindow( event.source );
}
}
});

These lines are every UNRESONABLE, because window message event is not revealjs ifself.

I am not sure if you heard an extension called wappalyzer

image

It will trigger that event handler.

image

Also, there are other project like giscus, are using the message event listener either.

Reveal.js Note plugin should never make sure that event.data is a string, and it can be successfuly JSON.parse.

You probably need to add a try {} catch {} block, and make extra check before rudely JSON.parse it.

@Mister-Hope
Copy link
Contributor Author

Mister-Hope commented Mar 14, 2022

Here is a reproduciton link, and the console is just like a mess if you have some extension using that even installed, or with project like giscus.

https://vuepress-theme-hope.github.io/v2/md-enhance/guide/presentation/themes.html

@Mister-Hope
Copy link
Contributor Author

Any update for this one? As fixing this should be easy.

@hakimel
Copy link
Owner

hakimel commented Mar 21, 2022

Thanks for the feedback—this has been fixed.

samwize pushed a commit to samwize/reveal.js that referenced this issue Jun 9, 2022
* hakimel/master: (1422 commits)
  tweak slides mention
  fix issues with overflowing fit-text when exporting to pdf hakimel#3191 hakimel#3120
  Fix typo in plugin.js
  notes plugin only listens for same-origin postmessages to prevent xss
  new attempt at speaker view xss fix
  add support for 'data-background-gradient' hakimel#2510
  fix issue where auto-animate did not work when jumping three or more slides (i.e. longer than the view distance)
  made data-background attribute work with .webp hakimel#3200
  fix: truncated long r-fit-text on pdf
  update link
  fix issue with hakimel#3182 when slide numbers are disabled
  fix inconsistent fragment visibility in looping presentations hakimel#3123
  fix: pdf page numbering for fragment group
  always use css transforms for presentation scaling (zoom has too many quirks even if it is slightly sharper on ldpi displays)
  update lock file
  4.3.1
  notes plugin allows messsages from current/upcoming slide windows
  fix hakimel#3154
  fix vertical slide link in demo hakimel#3155
  dont run full build + tests for package task hakimel#3156
  ...
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

2 participants