-
Notifications
You must be signed in to change notification settings - Fork 744
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
Avoid catastrophic backtracing in regex #1690
Avoid catastrophic backtracing in regex #1690
Conversation
lib/rouge/lexers/factor.rb
Outdated
@@ -243,7 +243,7 @@ def self.builtins | |||
end | |||
|
|||
# strings | |||
rule %r/"""\s+.*?\s+"""/, Str | |||
rule %r/"""[^"].*?[^"]"""/, Str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think this is wrong, let me fix that. Though I'm finding it hard to find what is actually supported in the Factor language. Does it need spaces after the triple quotes to be valid? Can it be split across multiple lines like this?
Test in GitHub:
article "ARTICLES" {
{ "title" "TITLE" { VARCHAR 256 } +not-null+ +user-assigned-id+ }
{ """title""" "TITLE" { VARCHAR 256 } +not-null+ +user-assigned-id+ }
{ ""title"" "TITLE" { VARCHAR 256 } +not-null+ +user-assigned-id+ }
{ """ title """ "TITLE" { VARCHAR 256 } +not-null+ +user-assigned-id+ }
{ """title over two
lines to test it""" "TITLE" { VARCHAR 256 } +not-null+ +user-assigned-id+ }
} define-persistent
: <article> ( title -- article ) article new swap >>title ;
TUPLE: revision id title author date content description ;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Looks like GitHub is parsing the code correctly'ish 🤔 The highlight for double quotes seems to be out of place but overall it looks good.
I was about to suggest lifting the regexes directly from Pygments
. However, it seems Pygments 2.8.1 (latest) - the Python package that Rouge compatible with - does not handle triple quotes well (could be an existing bug).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to factor/factor#1474, it seems like triple quotes are not supported.
@Ravlen What do you think about getting the regexes from Pygments? diff --git lib/rouge/lexers/factor.rb lib/rouge/lexers/factor.rb
index 2a18f715..4a7458a5 100644
--- lib/rouge/lexers/factor.rb
+++ lib/rouge/lexers/factor.rb
@@ -243,8 +243,9 @@ module Rouge
end
# strings
- rule %r/"""\s+.*?\s+"""/, Str
- rule %r/"(\\.|[^\\])*?"/, Str
+ rule %r/"""\s(?:.|\n)*?\s"""/, Str
+ rule %r/"(?:\\\\|\\"|[^"])*"/, Str
+ rule %r/\S+"\s+(?:\\\\|\\"|[^"])*"/, Str
rule %r/(CHAR:)(\s+)(\\[\\abfnrstv]*|\S)(?=\s)/, Str::Char
# comments |
@tancnle I like this idea. They're vetted/tested. |
Uses the same regex as pygments, and removes the triple quote regex, which isn't actually supported in factor
@tancnle @dblessing OK, updated with the regex from Pygments, but I dropped the |
Travis CI seems to be problematic 🤔 @dblessing could you help to check what is going wrong with Travis integration? |
It looks like we've run out of build minutes due to Travis' new billing - https://blog.travis-ci.com/2020-11-02-travis-ci-new-billing. We either need to apply for OSS allotment, or potentially use GitLab builds. What do you all think @tancnle @Ravlen. I think GitLab only offers 400 free minutes, but maybe they'd be willing to sponsor a 'plan' for Rouge? |
@dblessing Would it be much hassle to apply for an OSS allotment? It provides 10k credits which are build minutes I believe. I think BuildKite or CircleCI might be a better choice given they have no build minute limit for OSS. I am keen to give you a hand on the CI migration if needed. |
@tancnle I've applied for credits. But it's not 10,000 automatic - I had to request the amount I think we need. I asked if they had visibility into historical usage. But AFAICT we use about 10 minutes per build - 1 minute per suite and we test 10 Ruby versions. Probably just 500-1000 minutes will suffice. |
@dblessing I think moving to BuildKite or CircleCI with unlimited build minute will remove the need to recalculate the allotment as we scale our pipeline. But it might require some work.
That's a lot. Are we thinking about deprecating old Ruby versions (I.e. no ongoing supported for MRI < 2.5)? We can get those rolling on separate issues in the meanwhile, can't we? |
Is honestly prefer either to stay with Travis or move to GitLab.
I agree we should consider removing some Ruby version support.
|
No worries @dblessing. I am cool with staying with TravisCI and get this MR unblocked and merged. FYI I have created the issue to remove support for old Ruby version. |
@dblessing @tancnle If we want to switch to GitLab, I'm reasonably confident I could write the pipeline configuration. There are 50k minutes available for open source projects, see https://about.gitlab.com/solutions/open-source/, if we want to look into it (though perhaps you'd need to move the whole project to GitLab to get the full 50k?) |
I still haven't heard back from Travis so I pinged them again on the support issue. @Ravlen I think you're right - we'd need to either move the whole project or see if they would grant us a Premium license. I think the best case is Travis comes through for us, but if not we can see about GitLab CI. |
@dblessing Any news from Travis? If not, I think we can start migrating to another CI solution. |
@tancnle I thought I commented about 3 weeks ago saying we had CI
allocation and asking @Ravlan to push again. Either a malfunction or I only
dreamed it. Sorry all. It should be working now, though.
On Tue, May 18, 2021 at 7:06 PM Tan Le ***@***.***> wrote:
@dblessing <https://github.com/dblessing> Any news from Travis? If not, I
think we can start migrating to another CI solution.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1690 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AASIVFFMSNFZO6EJVGW3FJTTOL6J3ANCNFSM4Y5NLKIQ>
.
--
Drew
|
@tancnle @dblessing Yay, finally the Travis build worked 😁 |
I for one would be 100% down to move to gitlab, so long as we could preserve the state of the issue tracker. |
(And given that this software is used by gitlab I think it would be fitting :] ) |
@tancnle This PR attempts to fix some regex that could cause catastrophic backtracing, could you take a look?
For the
ghc_core
lexer:For the
factor
lexer: