Skip to content

Commit

Permalink
fix(parser): support encoded spaces in link URL (#420)
Browse files Browse the repository at this point in the history
looks like the `%` character was missing in the previous
fix for link URLs :/

also, prevent spaces in user-defined macro values.

Fixes #419

Signed-off-by: Xavier Coulon <[email protected]>
  • Loading branch information
xcoulon authored Sep 29, 2019
1 parent 22061e8 commit 6c57b55
Show file tree
Hide file tree
Showing 6 changed files with 2,352 additions and 2,307 deletions.
35 changes: 33 additions & 2 deletions pkg/parser/link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ next lines`
})

It("relative link with all valid characters", func() {
source := `a link to link:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~:/?#@!$&;=()*+,-_.[as expected]`
source := `a link to link:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~:/?#@!$&;=()*+,-_.%[as expected]`
expected := types.Paragraph{
Attributes: types.ElementAttributes{},
Lines: []types.InlineElements{
Expand All @@ -508,7 +508,7 @@ next lines`
types.InlineLink{
Location: types.Location{
types.StringElement{
Content: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~:/?#@!$&;=()*+,-_.",
Content: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~:/?#@!$&;=()*+,-_.%",
},
},
Attributes: types.ElementAttributes{
Expand All @@ -525,6 +525,37 @@ next lines`
Expect(source).To(EqualDocumentBlock(expected))
})

It("relative link with encoded space", func() {
source := `Test 1: link:/test/a b[with space]
Test 2: link:/test/a%20b[with encoded space]`
expected := types.Paragraph{
Attributes: types.ElementAttributes{},
Lines: []types.InlineElements{
{
types.StringElement{Content: "Test 1: link:/test/a b[with space]"},
},
{
types.StringElement{Content: "Test 2: "},
types.InlineLink{
Location: types.Location{
types.StringElement{
Content: "/test/a%20b",
},
},
Attributes: types.ElementAttributes{
types.AttrInlineLinkText: types.InlineElements{
types.StringElement{
Content: "with encoded space",
},
},
},
},
},
},
}
Expect(source).To(EqualDocumentBlock(expected))
})

Context("text attribute with comma", func() {

It("relative link only with text having comma", func() {
Expand Down
Loading

0 comments on commit 6c57b55

Please sign in to comment.