System user replaces wrong URL when it downloads local copy of image

Hmm, a bit off-topic, but did the system user replace the wrong image URL (within the code fences) after downloading the local copy?

That looks wrong to me.

3 Likes

Yeah that is absolutely a bug, can you separate item on it?

I vaguely recall this was opened in the past with a status denied…

Honestly I do not think we should ever be mucking with raw and only apply this kind of magic to cooked. I think that is the root of this bug.

If we are mucking with raw fixing this is actually quite a giant headache cause we would need to do the replacement in a reverse markdown parser or hoist stuff using magics.

5 Likes

This looks like that:

I found one direct reference to this topic, but it was closed so I couldn’t piggyback off of it. I have some cases where the URL of an image is of minor significance, but certainly not of paramount importance. Overall, I prefer to have the nicety of locally cached images, but there’s a few cases where I’d like to escape that context especially in code blocks of specific posts.
https://meta.discourse.org/t/remote-image-download-shouldnt-touch-code-sections/13823

Might there be a way to do it on a by-post or by-topic basis? How about a tag that or html component that tells that feature to ignore the post? This is certainly not a high priority thing and I wouldn’t spend a lot of cycles on it, I just thought I’d bring it up again to see if there may have been any architectural changes that makes this an easier fix.

The best workaround I’ve found is just to screenshot the text in it’s original form, but that of course doesn’t allow for easy copying from the code blocks.

1 Like

Nice old bug report you dug up! I swear we have a more recent report of this that is still open and active, but I’m failing at search right now.

Are you including the image link two times? Once as normal link and once within a code block? If so, then it’s this bug.

4 Likes

I am linking twice, once in a code block and once as the real image. Both links are replaced with the same /uploads/default/.../... url

The curious instance about this thread’s OP’s report is that the original image is nowhere in the post raw - it’s only in the embed.

Yesterday I wrote up a little howto for using html to align images - love that little hack by @awesomerobot and my colleagues will be excited about it. However I noticed that in my code example the image urls got changed from placekitten.com to the local upload. Not a big deal in this case and I realize this is probably impossible to prevent but it seems unfortunate that a code example can be messed up like this automatically by discourse.

The only way to stop it I guess would be to disable the copy to local feature, which I definitely do not want to do. :slight_smile:

1 Like

Moved your post here @tobiaseigen, sounds like the same issue (url in code block being replaced).

3 Likes

@nbianca can you make sure we never change URLs in code blocks? (We need to hoist code blocks before doing the search/replace)

1 Like

I remember this being exceedingly complicated, are we sure this isn’t a big risk? There’s a reason we avoided it until now…

2 Likes

Attempt #2 cause imgur was disabled at the time as a target:

I just hotlinked: https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png

It is hotlinked :arrow_double_down:

I quoted it here: https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png

And added an IMG tag here:

This is how the code for the post looks:

Attempt #2 cause imgur was disabled at the time as a target:

I just hotlinked: https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png

It is hotlinked :arrow_double_down: 

<img src='//assets-meta-cdck-prod-meta.s3.dualstack.us-west-1.amazonaws.com/original/3X/2/6/26f471f6ebe3b11557506f6ae96156e0a3852e5b.png'>

I quoted it here: https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png


And added an IMG tag here:

<img src='//assets-meta-cdck-prod-meta.s3.dualstack.us-west-1.amazonaws.com/original/3X/2/6/26f471f6ebe3b11557506f6ae96156e0a3852e5b.png'></img>


This is how the code for the post looks:

This is it in an inline code block https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png

1 Like

Yeah this is a nightmare level fix we basically need a reverse markdown parser to do this correctly, I do not want to take this on right now. One day … maybe… but not today.

4 Likes

My bad, since we added some hoisting I thought it was the same issue. Turns out, we added hoisting on the cooked version, not the raw version.

This is indeed a completely different level of :exploding_head:

4 Likes

I wouldn’t even assign this, it can remain in our long term todos. It’s a rare case anyways.

3 Likes