Skip to content

Commit

Permalink
Fix for links ending in parentheses (fixes #392)
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumBadger committed Jul 11, 2017
1 parent 98b2659 commit 7cfdbd7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions assets/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
80/1.9.9
Preference to enable video playback controls (thanks to ahomphophone)
Perform temporary file pruning in the background
Fix for links ending in parentheses
Crash fixes
Translation updates (thanks to verdulo)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ private static void linkify(final IntArrayLengthPair input, final IntArrayLength
final int linkPrefixEndPos = linkPrefixes[linkStartType].length + linkStartPos;
int linkEndPos = linkPrefixEndPos;

boolean hasOpeningParen = false;

while(linkEndPos < input.pos) {

final int lToken = input.data[linkEndPos];
Expand All @@ -176,6 +178,10 @@ private static void linkify(final IntArrayLengthPair input, final IntArrayLength
&& lToken != TOKEN_BRACKET_SQUARE_OPEN
&& lToken != TOKEN_BRACKET_SQUARE_CLOSE;

if(lToken == '(') {
hasOpeningParen = true;
}

if(isValidChar) {
linkEndPos++;
} else {
Expand All @@ -201,7 +207,7 @@ private static void linkify(final IntArrayLengthPair input, final IntArrayLength
linkEndPos--;
}

if(input.data[linkEndPos - 1] == ')') {
if(!hasOpeningParen && input.data[linkEndPos - 1] == ')') {
linkEndPos--;
}

Expand Down

0 comments on commit 7cfdbd7

Please sign in to comment.