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

Image with link in markdown not working properly #2636

Closed
bouffa opened this issue Feb 16, 2016 · 12 comments
Closed

Image with link in markdown not working properly #2636

bouffa opened this issue Feb 16, 2016 · 12 comments
Labels
💊 bug Something isn't working status: needs feedback Tell me more about it
Milestone

Comments

@bouffa
Copy link
Contributor

bouffa commented Feb 16, 2016

Hi,

Image links in markdown are not working properly. Sometimes, the link is replaced with the image url.

For example, this markdown command :
[![Project Stats](image_url)](link_url)

sometimes produces a link to image_url instead of link_url :

<a href=image_url><img src=image_url /> </a>

instead of

<a href=link_url><img src=image_url /> </a>

The problem can be reproduced on https://try.gogs.io (Gogs Version: 0.8.37.0215):

https://try.gogs.io/chengbs/Openfire/src/3.10/README.md

The link of the first badge (travis-ci) is correct, but the second (openhub badge) is linking to the gif image.

Project Stats

Thanks,

@unknwon unknwon added the 💊 bug Something isn't working label Feb 16, 2016
@unknwon
Copy link
Member

unknwon commented Feb 16, 2016

Right now, only image path ends with .svg will produce a link to link, not image itself...

@MrDark
Copy link

MrDark commented Mar 17, 2016

Found the same problem in the latest develop build (0.9.12.0316)

Markdown:
[![Alt Text](http://image_url)](http://google.com)
Html:
<p><a href="http://google.com" rel="nofollow"></a><a href="http://image_url" rel="nofollow"><img src="http://image_url" alt="Alt Text"></a></p>

For full example:
https://try.gogs.io/Mr_Dark/Markdown-Test/src/master/README.md

@unknwon
Copy link
Member

unknwon commented Mar 17, 2016

I think I said something very clear...

@DavidVentura
Copy link

DavidVentura commented Jun 21, 2016

I think the mimetype is wrong for svg images. When accessing a readme file with a linked svg image gogs offers a 'plain' file; even following the presented link just shows me the text because the mimetype is wrong

@strk
Copy link
Contributor

strk commented Jul 25, 2016

Confirmed, this snippet also doesn't work on gogs:

[![build status]
(https://drone.osgeo.kbt.io/api/badges/geos/php-geos/status.svg?branch=master)]
(https://drone.osgeo.kbt.io/geos/php-geos?branch=master, alt=build status)

That is, it only produces the image, but not the link, as it should:

[build status](https://drone.osgeo.kbt.io/geos/php-geos?branch=master, alt=build status)

@strk
Copy link
Contributor

strk commented Jul 25, 2016

@unknwon ending or not with .svg doesn't make a difference, see here:
https://try.gogs.io/strk/test1/issues/5

@strk
Copy link
Contributor

strk commented Jul 25, 2016

Putting the image and link text onto the same line seems to fix the issue:

[![build status]
(https://drone.osgeo.kbt.io/api/badges/geos/php-geos/status.svg?branch=master)](https://drone.osgeo.kbt.io/geos/php-geos?branch=master, alt=build status)

[build status](https://drone.osgeo.kbt.io/geos/php-geos?branch=master, alt=build status)

This is not a problem on github.

osgeo-gogs pushed a commit to libgeos/php-geos that referenced this issue Jul 25, 2016
There needs be no newline between image url and target url.
See gogs/gogs#2636 (comment)
@strk
Copy link
Contributor

strk commented Jul 25, 2016

I was wrong, single-line doesn't fix it either:
https://try.gogs.io/strk/test1/issues/5#issuecomment-948

@drm
Copy link

drm commented Aug 15, 2016

@unknwon As I understand the rationale behind the code, it is there to have internally linked images being served from raw instead of src. But it also checks for links being absolute, i.e., have a protocol (validLinksPattern).

It seems to me that there are two issues here:

  • the processing should only occur for internal links, i.e., links that match the current working tree, or at least only the gogs instance. Can you maybe write up a list of test cases that should work, as you probably know better what the original reasoning behind the code was?
  • On the other hand, if the link already is inside an <a href...>...</a>, then it would not make sense processing it at all. That would probably be a more robust fix anyway. Maybe (r *Renderer) Image() can do a reverse scan on the output buffer to check if there is an unclosed a tag already in the buffer.

@strk
Copy link
Contributor

strk commented Aug 30, 2016

Meanwhile I've figured my own issue, and filed it as #3545

@unknwon unknwon added this to the 0.10.0 milestone Sep 1, 2016
@unknwon unknwon modified the milestones: 0.11.0, 0.10.0 Feb 11, 2017
@unknwon unknwon added the status: needs feedback Tell me more about it label Feb 23, 2017
@unknwon
Copy link
Member

unknwon commented Feb 23, 2017

Patch has pushed to fix this issue, please test on develop branch or https://try.gogs.io/gogs/gogs.

@unknwon
Copy link
Member

unknwon commented Feb 23, 2017

Sorry, not develop branch, it's release/0.11.

@unknwon unknwon closed this as completed Feb 28, 2017
ethantkoenig pushed a commit to ethantkoenig/gogs that referenced this issue Oct 13, 2017
* Use search component on org invitation user input.

* Search component for collaboration and members.

* Search component for repo search.

* minCharacters for search input

* Display full_name for user search.

* Fixed missing uid query parameter for repo search.

* Removed unused comment.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💊 bug Something isn't working status: needs feedback Tell me more about it
Projects
None yet
Development

No branches or pull requests

6 participants