Skip to content
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 crash with empty transclusions #8145

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Jermolene
Copy link
Owner

This PR addresses infinite loops that can occur when {{}} is typed in the editor with the preview displayed. See #8144 for an example, but this is a long standing problem. See #7768 for an earlier attempt to fix this problem

The approach taken here is to modify the parse rules for both inline and block transclusions so that the transclusion is not recognised unless there is a non-blank target and/or template.

Copy link

vercel bot commented Apr 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
tiddlywiki5 ✅ Ready (Inspect) Visit Preview Apr 15, 2024 11:43am

@pmario
Copy link
Contributor

pmario commented Apr 15, 2024

hmmm, That's OK for

<$button>{{}}

But it is still a problem with "unfinished" code as follows.

<$button><$transclude>

@Jermolene
Copy link
Owner Author

hmmm, That's OK for

@pmario yes this is only a fix for #8144. I agree we still have a problem with recursive transclusions, but as you well know that is a much, much subtler problem. The benefit of the fix here is that it doesn't even parse {{}} as a transclusion, which makes it clearer that it is an invalid construction (particularly if we had syntax highlighting), and we don't need to engage any recursion detection which will always of necessity be resource intensive.

@pmario
Copy link
Contributor

pmario commented Apr 15, 2024

I do think that this PR is an improvement for many users already. I think it should be included.

But I also think, that we need a runtime fix for my code. From time to time I do have a problem with this type of code at runtime. Especially if variables have a typo and are therefore empty

@bluepenguindeveloper
Copy link

It works as stated (doesn't fix a more longstanding recursion issue but does fix the specific issue in #8144 by not treating {{}} as a transclusion), but I do have a doubt: sometimes in templates or lists etc., we might want to transclude the text of the current tiddler, like {{!!text}}, but if {{}} was heretofore equivalent to {{!!text}} and if anyone is currently using {{}} instead of {{!!text}} before, then this might be considered a breaking change.

@pmario
Copy link
Contributor

pmario commented Apr 16, 2024

@bluepenguindeveloper -- I am creating a second PR atm, which tries to solve the "runtime" side of that problem. From time to time I'm also a "victim" of that problem especially since development where the code is still buggy.

@Jermolene
Copy link
Owner Author

It works as stated (doesn't fix a more longstanding recursion issue but does fix the specific issue in #8144 by not treating {{}} as a transclusion), but I do have a doubt: sometimes in templates or lists etc., we might want to transclude the text of the current tiddler, like {{!!text}}, but if {{}} was heretofore equivalent to {{!!text}} and if anyone is currently using {{}} instead of {{!!text}} before, then this might be considered a breaking change.

Thanks @bluepenguindeveloper. This PR only changes the behaviour where the trimmed contents of the {{}} are empty, and doesn't affect the processing of {{!!text}}.

This is indeed not strictly backwards compatible because {{}} is currently valid as a synonym for <$transclude/>, which is in turn interpreted as transcluding the current tiddler. However {{}} isn't used by the core, and so I suspect is not a common usage.

Perhaps the best way to assess the backwards compatibility impact of this PR is to go ahead and merge it so that it gets tested in the prerelease.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants