You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@neffets I've just pushed a new branch with a partial fix for this. Could you try out the issue-168 branch and let me know how that works for you. Could you please also verify that the issue you reported in #167 still exists in that branch.
@eliph@neffets - I've pushed an update to the issue-168 branch (link mentioned above) that should improve the detection of the start-of-link quote. Would appreciate if folks would test test this.
@netcarver: Generally I would not not consider bad usage of the Textile syntax a "bug", as already pointed out. Hopefully, this change will not result in breaking other, complex situations where Textile is used correcly.
Hi @eliph - this has not caused any of the existing test cases to fail. It also makes php-textile more resilient to typos in otherwise correct link text. If you know of any examples that this change would negatively impact, please make them known so I can include them in the test cases and work towards getting them fixed.
--- vendor/netcarver/textile/src/Netcarver/Textile/Parser.php-3.6.0 2018-10-09 09:23:42.792001373 +0000
+++ vendor/netcarver/textile/src/Netcarver/Textile/Parser.php 2018-10-09 15:38:24.667558319 +0000
@@ -3627,16 +3627,27 @@
}
}
- // Rebuild the link's text by reversing the parts and sticking them back
- // together with quotes.
- $link_content = implode('"', array_reverse($linkparts));
-
- // Rebuild the remaining stuff that goes before the link but that's
- // already in order.
- $pre_link = implode('"', $possible_start_quotes);
-
- // Re-assemble the link starts with a specific marker for the next regex.
- $slice = $pre_link . $this->uid.'linkStartMarker:"' . $link_content;
+ if ($balanced > 0) {
+ // We found more end-quotes than start quotes. We can try to correct this if there are 'ambiguous' quotes
+ // present. Ambiguous quotes are quotes that appear with spaces on each side - such that they are not
+ // obviously a start or an end quote.
+ $replaced = 0;
+ $slice = preg_replace('~ +" +~'.$mod, ' '.$this->uid.'linkStartMarker:"', $slice, 1, $replaced);
+ if ($replaced == 0) {
+ $slice = preg_replace('~^" +~m'.$mod, $this->uid.'linkStartMarker:"', $slice, 1, $replaced);
+ }
+ } else {
+ // Rebuild the link's text by reversing the parts and sticking them back
+ // together with quotes.
+ $link_content = implode('"', array_reverse($linkparts));
+
+ // Rebuild the remaining stuff that goes before the link but that's
+ // already in order.
+ $pre_link = implode('"', $possible_start_quotes);
+
+ // Re-assemble the link starts with a specific marker for the next regex.
+ $slice = $pre_link . $this->uid.'linkStartMarker:"' . $link_content;
+ }
}
// Add the last part back
Activity
neffets commentedon Jul 11, 2016
combined bug. if a second line have a broken link (caused by space-linktext),
then a former correct link will be broken too
e.g.
will get you two broken / not-evaluated links. line one alone will get you an correct evaluated link.
eliph commentedon Jul 14, 2016
Broken syntax will generate broken code, in any language.
Apply fix for issue #168
netcarver commentedon Jul 21, 2016
@neffets I've just pushed a new branch with a partial fix for this. Could you try out the issue-168 branch and let me know how that works for you. Could you please also verify that the issue you reported in #167 still exists in that branch.
Many thanks!
netcarver commentedon Jul 23, 2016
@eliph I'd like to make the handling of this case more robust if I can - but I agree with your sentiment here.
netcarver commentedon Jul 25, 2016
@eliph @neffets - I've pushed an update to the issue-168 branch (link mentioned above) that should improve the detection of the start-of-link quote. Would appreciate if folks would test test this.
5 remaining items
Fix for latest report in #168
netcarver commentedon Jul 28, 2016
@neffets Just pushed a correction that should cover this case. Please test again.
eliph commentedon Jul 28, 2016
@netcarver: Generally I would not not consider bad usage of the Textile syntax a "bug", as already pointed out. Hopefully, this change will not result in breaking other, complex situations where Textile is used correcly.
netcarver commentedon Jul 28, 2016
Hi @eliph - this has not caused any of the existing test cases to fail. It also makes php-textile more resilient to typos in otherwise correct link text. If you know of any examples that this change would negatively impact, please make them known so I can include them in the test cases and work towards getting them fixed.
neffets commentedon Jul 28, 2016
Thanx @eliph , with last commit it is now working completely, all links work.
netcarver commentedon Jul 28, 2016
@neffets Thank you for testing that. I'll leave this open a few more days in case there is more feedback.
neffets commentedon Oct 9, 2018
Hello, i tried v3.6.0 it fixes issue #167, but issue #168 has still problems.
Example-1:
Example-2:
I need a little patch in line 3630 like former issue-168 patch
patch.Netcarver_Textile_Parser-118.txt
--- vendor/netcarver/textile/src/Netcarver/Textile/Parser.php-3.6.0 2018-10-09 09:23:42.792001373 +0000 +++ vendor/netcarver/textile/src/Netcarver/Textile/Parser.php 2018-10-09 15:38:24.667558319 +0000 @@ -3627,16 +3627,27 @@ } } - // Rebuild the link's text by reversing the parts and sticking them back - // together with quotes. - $link_content = implode('"', array_reverse($linkparts)); - - // Rebuild the remaining stuff that goes before the link but that's - // already in order. - $pre_link = implode('"', $possible_start_quotes); - - // Re-assemble the link starts with a specific marker for the next regex. - $slice = $pre_link . $this->uid.'linkStartMarker:"' . $link_content; + if ($balanced > 0) { + // We found more end-quotes than start quotes. We can try to correct this if there are 'ambiguous' quotes + // present. Ambiguous quotes are quotes that appear with spaces on each side - such that they are not + // obviously a start or an end quote. + $replaced = 0; + $slice = preg_replace('~ +" +~'.$mod, ' '.$this->uid.'linkStartMarker:"', $slice, 1, $replaced); + if ($replaced == 0) { + $slice = preg_replace('~^" +~m'.$mod, $this->uid.'linkStartMarker:"', $slice, 1, $replaced); + } + } else { + // Rebuild the link's text by reversing the parts and sticking them back + // together with quotes. + $link_content = implode('"', array_reverse($linkparts)); + + // Rebuild the remaining stuff that goes before the link but that's + // already in order. + $pre_link = implode('"', $possible_start_quotes); + + // Re-assemble the link starts with a specific marker for the next regex. + $slice = $pre_link . $this->uid.'linkStartMarker:"' . $link_content; + } } // Add the last part backprevent unbalanced slices and allow link-textes over more than one li…
Test for multiline links