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 promises at EOF #4097

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

Fix promises at EOF #4097

wants to merge 2 commits into from

Conversation

b4n
Copy link
Member

@b4n b4n commented Oct 8, 2024

getInputLineOffset() was giving very wrong results at EOF, leading to overlong promises, leading to crashes in building the narrowed input stream (see e.g. newly introduced test case, and geany/geany#3939).

I'm unsure if this is a good way to fix the issue, but I couldn't find a better one; but admittedly I didn't poke around this code for a long time, and it got a fair bit more complicated with its newer features, so I might have missed something.

The previous computation could result in invalid values, which could
lead to invalid promise ranges and subsequent crashes.
Copy link

codecov bot commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.72%. Comparing base (ecf0c4a) to head (fcab90a).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4097   +/-   ##
=======================================
  Coverage   85.72%   85.72%           
=======================================
  Files         239      239           
  Lines       56961    56963    +2     
=======================================
+ Hits        48827    48829    +2     
  Misses       8134     8134           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@masatake
Copy link
Member

masatake commented Oct 9, 2024

Thank you.

it got a fair bit more complicated with its newer features

I agree with you. Some issues I have opened these days are related to this area.
Eventually, I must revise the whole area after merging this pull request.

I will review this.

body input.php /^<div id="body">$/;" I line:26 language:HTML roles:def
content input.php /^ <main id="content">$/;" I line:27 language:HTML roles:def
post input.php /^ <article class="post" id="post-<?p/;" c line:31 language:HTML roles:attribute
post-<?p input.php /^ <article class="post" id="post-<?p/;" I line:31 language:HTML roles:def
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a follow-up to fix the HTML promise range from the PHP lexer to fix this spurious <?p, but it currently depends on these changes so I'll post it after this is sorted out (no pressure, just saying that indeed, this tag is not exactly as it should be).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you paste this comment into the commit log for this commit?
So people can understand this commit from its log only with 'git log'.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want, but I'm not sure its so important to specify in the commit, it's just a note for review that it's not to be worried about, but I don't think it undermines the patch much.
Another option could be removing this line from the test case and add a new one for the other patch, I merely kept it like this because it's a "real" file and made me notice the issue.

Anyway, I can do either just fine, as you prefer :)

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.

2 participants