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

Reader breaks when post contains an image #1

Open
aerugo opened this issue May 24, 2020 · 4 comments
Open

Reader breaks when post contains an image #1

aerugo opened this issue May 24, 2020 · 4 comments
Assignees

Comments

@aerugo
Copy link

aerugo commented May 24, 2020

See this topic:
https://bbu.world/t/beautiful-eyes/942

Rendered here:
https://read.babelbetween.us/#/t/942

@jims jims self-assigned this May 27, 2020
@jims
Copy link
Collaborator

jims commented May 27, 2020

This seems like a bit of a more hairy bug to fix. How would you prioritize it? I did some initial investigation and there is something with the html in that post that trips up the html parser. I haven't yet found a minimal repro case but have narrowed it down a bit.

@aerugo
Copy link
Author

aerugo commented May 27, 2020

That the threads don't load at all is unfortunate, since that means we would have to prohibit the writers from including images, which would be a shame.

I made an example thread here for us and assigned you the top post so you can edit it: https://bbu.world/t/you-are-very-high-up/57

Maybe if you can get a print-out of the incoming HTML as the parser sees (in case there is pre-processing) it and we can try to debug together?

@aerugo
Copy link
Author

aerugo commented May 27, 2020

I think the solution is to remove all lightbox-wrapper elements from the DOM. At least, that solved a related problem in a Javascript app that also eats Discourse posts. Not sure if that's applicable here.

   processCookedPost(post) {
      var div = document.createElement('div');
      div.innerHTML = post;
      var lightboxes = div.getElementsByClassName('lightbox-wrapper');
      while (lightboxes[0])
         lightboxes[0].parentNode.removeChild(lightboxes[0])
      var images = div.getElementsByTagName('img');
      while (images[0])
         images[0].parentNode.removeChild(images[0])
      var repl = div.innerHTML;
      return repl
    }

@aerugo
Copy link
Author

aerugo commented Jun 1, 2020

Just to note, code above also removes images. Ideally, they would be jerked out of the lightbox div but still displayed. However, not displaying them at all is better than breaking the display.

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