-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 URL handling in the whole markdown module, improve test coverage (fix #997) #1027
Conversation
@@ -9,4 +9,5 @@ type MarkdownOption struct { | |||
Text string | |||
Mode string | |||
Context string | |||
Wiki string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Public Gitea API changed, optional Wiki parameter added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you have to send a PR to SDK project at first before this can be merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lunny done.
@@ -74,7 +75,7 @@ func TestAPI_RenderGFM(t *testing.T) { | |||
<ul> | |||
<li><a href="` + AppSubURL + `wiki/Links" rel="nofollow">Links, Language bindings, Engine bindings</a></li> | |||
<li><a href="` + AppSubURL + `wiki/Tips" rel="nofollow">Tips</a></li> | |||
<li>Bezier widget (by <a href="` + AppURL + `r-lyeh" rel="nofollow">@r-lyeh</a>)<a href="` + AppSubURL + `issues/786" rel="nofollow">#786</a></li> | |||
<li>Bezier widget (by <a href="` + AppURL + `r-lyeh" rel="nofollow">@r-lyeh</a>)<a href="https://github.com/ocornut/imgui/issues/786" rel="nofollow">#786</a></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, link hosts are no longer rewritten. No more dead links.
res += "/" | ||
} | ||
} | ||
cwdIndex := strings.Index(res, "/./") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URLJoin
now correctly handles .
and ..
path elements.
@@ -92,10 +92,10 @@ var ( | |||
ShortLinkPattern = regexp.MustCompile(`(\[\[.*\]\]\w*)`) | |||
|
|||
// AnySHA1Pattern allows to split url containing SHA into parts | |||
AnySHA1Pattern = regexp.MustCompile(`http\S+//(\S+)/(\S+)/(\S+)/(\S+)/([0-9a-f]{40})(?:/?([^#\s]+)?(?:#(\S+))?)?`) | |||
AnySHA1Pattern = regexp.MustCompile(`(http\S*)://(\S+)/(\S+)/(\S+)/(\S+)/([0-9a-f]{40})(?:/?([^#\s]+)?(?:#(\S+))?)?`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Protocol is important now.
@@ -9,4 +9,5 @@ type MarkdownOption struct { | |||
Text string | |||
Mode string | |||
Context string | |||
Wiki string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you have to send a PR to SDK project at first before this can be merged.
LGTM except the Wiki type should be bool |
Amended with string to bool change in API SDK. Signed-off-by: Andrew Boyarshin <andrew.boyarshin@gmail.com>
In case someone hasn't noticed, I force-pushed amended commits to both gitea and gitea-sdk repos with string -> bool change. Review for the final LGTM? |
LGTM |
Pending merge. |
As it is in the title.
Plus, links to issues or PRs in external repositories will no longer be rewritten to current repo.
Fixes issue #997. Merging this PR will increase coverage to 32.4% from 31.8%.