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

fix(pr): fix broken markdown when version contains '|' #6235

Closed
wants to merge 7 commits into from

Conversation

djcsdy
Copy link
Contributor

@djcsdy djcsdy commented May 14, 2020

Fixes broken markdown in PRs caused by version ranges containing |.

For an example of what I mean, see this PR: softwareventures/tslint-rules#25

Notice that the table markup is broken because the target version range is ^1.9.3 || ^2.0.0, and | is interpreted by markdown as a table cell delimiter.

Closes #5397

@djcsdy djcsdy marked this pull request as draft May 14, 2020 13:50
Copy link
Collaborator

@rarkins rarkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check how this impacts the various platforms we support. If they handle this differently then we may need to move this massaging logic into each platform's markdown massage logic.

@lgtm-com
Copy link

lgtm-com bot commented May 14, 2020

This pull request introduces 1 alert when merging 92ce4aa into 61c4fcd - view on LGTM.com

new alerts:

  • 1 for Incomplete string escaping or encoding

@djcsdy
Copy link
Contributor Author

djcsdy commented May 14, 2020

@rarkins OK. Fair point. I took a look at some of the platforms I know to be supported by Renovate.

GitHub: This change should work as-is. Using <code> instead of backtick and &#183; instead of | also works, and is more compatible with CommonMark so might be more future-proof.

Gitlab: Exactly like GitHub.

BitBucket: It’s impossible to fix this problem, because BitBucket’s flavour of markdown doesn’t support escaping |. It’s not possible to fall back to HTML either because, although BitBucket’s documentation says that “a restricted set of HTML tags” is supported, my testing suggests that the restricted set they’re referring to is the empty set.

Gitea: no change is required, the formatting worked as it was.

CommonMark (0.29): my reading of the spec is that Gitea’s behaviour is correct. No surprises here: the open source project matches the spec, Atlassian’s implementation is, as usual, terrible, and the others are somewhere in between.

So... I guess this could be considered a bug in GitHub, Gitlab, and BitBucket, and not in Renovate. It’s still really annoying though.

I see that there is some platform-specific code in the platform directory. If you’d welcome platform-specific fixes for this problem I’d be happy to oblige. Let me know if you have any suggestions.

@viceice
Copy link
Member

viceice commented May 14, 2020

See here: #3799 (comment)
I've tested almost all our supported platforms

@rarkins
Copy link
Collaborator

rarkins commented May 14, 2020

Can we fix this using our getPrBody() functions for each platform? They are a bit misnamed these days - should maybe be massagedMarkdown() or something similar

@viceice
Copy link
Member

viceice commented May 14, 2020

Should be doable, I think bitbucket server is now fixed too, so we can use the escaped variant there too.

@rarkins
Copy link
Collaborator

rarkins commented May 14, 2020

So we default to the "correct" way (that gitea supports) and then massage it to escaped on other platforms?

@viceice
Copy link
Member

viceice commented Jul 10, 2020

@djcsdy @rarkins I want to summarize what needs to be done here.

  • All platforms (excerpt gittea) are render the pipes wrong (current state).
  • with this change only bitbucket cloud will render the pipes wrong (as before).
  • this change is not nessessary for gittea but works there too.

So what shpould we do here? replacing it in getPrBody of platfrom can be difficult, can be replace additional places where not appropriate.

@rarkins
Copy link
Collaborator

rarkins commented Jul 11, 2020

@viceice let's leave bitbucket cloud broken for now then, so that we can move forward with the others.

@rarkins rarkins marked this pull request as ready for review July 11, 2020 10:21
Copy link
Collaborator

@rarkins rarkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test or two though

@rarkins
Copy link
Collaborator

rarkins commented Aug 3, 2020

@djcsdy @viceice I'm a bit confused as to the status of this. Does this PR still fix things?

@viceice
Copy link
Member

viceice commented Aug 3, 2020

Yes, escaping is more standard and fixes bitbucket server. Bitbucket cloud is broken with both. Other platforms work before and after.

@rarkins
Copy link
Collaborator

rarkins commented Aug 3, 2020

From a virus code review, I can't work out what difference this PR makes

@viceice
Copy link
Member

viceice commented Aug 3, 2020

It escapes the pipe in version ranges. See linked or for broken GitHub PR. So this will fix GitHub pr's too

@viceice
Copy link
Member

viceice commented Aug 3, 2020

I try to add a test PR for current state tomorrow, so we can see this pr failing and fix text afterwards.

@rarkins
Copy link
Collaborator

rarkins commented Aug 4, 2020

@viceice I'm confused because I don't notice any change to the escaping:

image

@rarkins rarkins marked this pull request as draft August 5, 2020 07:14
@djcsdy
Copy link
Contributor Author

djcsdy commented Aug 5, 2020

The important part of this PR was this line:

https://github.com/renovatebot/renovate/pull/6235/files#diff-464116b52af741627d80e2939c215721L65

But someone has already implemented the equivalent change in master. So this PR is redundant now.

@viceice

This comment has been minimized.

@viceice viceice closed this Sep 1, 2020
@viceice
Copy link
Member

viceice commented Sep 1, 2020

already fixed in #6514

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

renovate-bot open a PR with wrong Markdown table rendering result
3 participants