mkaczanowski / pastebin

Simple, fast, standalone pastebin service
MIT License
155 stars 27 forks source link

Recent commits broke submitting new paste #10

Closed chrisguida closed 3 years ago

chrisguida commented 3 years ago

Hi, I can no longer post anything if I use the most recent version of the docker image. It seems to be an issue with calling "init_plugins()" in custom.js. This error is printed to the console upon launching the page:

Uncaught SyntaxError: unexpected token: '&'
new:261:23
jQuery.Deferred exception: init_plugins is not defined @http://localhost:8000/static/custom.js:45:5
j@https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:29999
g/</k<@https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:30313
 undefined jquery.min.js:2:31579
Uncaught ReferenceError: init_plugins is not defined
    <anonymous> http://localhost:8000/static/custom.js:45
    jQuery 2

Seems it doesn't like this line in init_plugins():

var holder &#x3D; $(&#x27;#pastebin-code-block:first&#x27;).get(0); if (holder) { Prism.highlightElement(holder); }

Am I doing something wrong?

Thanks,

--Chris

chrisguida commented 3 years ago

This is also happening outside of the docker image, just using cargo.

chrisguida commented 3 years ago

Just ran the command you sent:

docker run --network host mkaczanowski/pastebin --address localhost --port 8000

Then went to Firefox and entered a message into the textbox, then hit Send. No change, no success message, nothing. Just to make sure, I deleted mkaczanowski/pastebin:latest from my local docker images and ran it again. Same problem. I've attached what the debug window looks like. When I reset git back to two commits ago, the sending works and I don't get this error message. Same problem on Chrome, same error message.

--Chris

On Tue, Oct 27, 2020 at 5:11 PM Mateusz Kaczanowski < notifications@github.com> wrote:

hmm. I can't repro this...

docker run --network host mkaczanowski/pastebin --address localhost --port 8000

and then on chrome it works fine, can you paste me a few screenshots of what you see?

chrisguida commented 3 years ago

I guess github doesn't pick up attachments from emails, and for some reason I don't see your comment here on this issue, but here's the screenshot I sent

Screenshot from 2020-10-27 18-11-08

mkaczanowski commented 3 years ago

huh, after cloning repo again I see the same issue. Dunno how rust compiler caches things but for sure I couldn't see this.

Anyway, thanks for reporting. The issue is that js_init gets escaped, so I enforced no_escape: https://github.com/mkaczanowski/pastebin/commit/661b4a8869e80c955be2ffc718dc9a2319420668

chrisguida commented 3 years ago

Sweet, thanks!