hugolib: Fix shortcode output wrapped in p
authorgllera <gabriellleragarcia@gmail.com>
Fri, 17 Aug 2018 00:17:27 +0000 (02:17 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 17 Aug 2018 07:13:30 +0000 (09:13 +0200)
Fixes #1642

hugolib/shortcode.go

index 8ad53993577a30f397586dfc4b965a551aeb39b9..c2fcf1b8d0f521d137da5349369258f9fb79ab17 100644 (file)
@@ -670,7 +670,6 @@ func replaceShortcodeTokens(source []byte, prefix string, replacements map[strin
                return source, nil
        }
 
-       sourceLen := len(source)
        start := 0
 
        pre := []byte("HAHA" + prefix)
@@ -694,7 +693,7 @@ func replaceShortcodeTokens(source []byte, prefix string, replacements map[strin
 
                // Issue #1148: Check for wrapping p-tags <p>
                if j >= 3 && bytes.Equal(source[j-3:j], pStart) {
-                       if (k+4) < sourceLen && bytes.Equal(source[end:end+4], pEnd) {
+                       if (k+4) < len(source) && bytes.Equal(source[end:end+4], pEnd) {
                                j -= 3
                                end += 4
                        }