GithubHelp home page GithubHelp logo

Comments (4)

derula avatar derula commented on May 27, 2024

At least one crash is actually a sievelib bug. The following script crashes the sievelib parser:

if address :domain "" ""){}

Traceback:

Traceback (most recent call last):
  File "~\.virtualenvs\strainer-40YVjBHe\lib\site-packages\sievelib\parser.py", line 400, in parse
    if not self.__command(ttype, tvalue):
  File "~\.virtualenvs\strainer-40YVjBHe\lib\site-packages\sievelib\parser.py", line 322, in __command
    self.__up()
  File "~\.virtualenvs\strainer-40YVjBHe\lib\site-packages\sievelib\parser.py", line 157, in __up
    if self.__curcommand.must_follow is not None:
AttributeError: 'NoneType' object has no attribute 'must_follow'

from strainer.

derula avatar derula commented on May 27, 2024

In master, the problem still exists, but traceback is a bit different:

Traceback (most recent call last):
  File "~/sievelib/sievelib/parser.py", line 435, in parse
    if not self.__command(ttype, tvalue):
  File "~/sievelib/sievelib/parser.py", line 375, in __command
    if self.__cstate(ttype, tvalue):
  File "~/sievelib/sievelib/parser.py", line 328, in __arguments
    if self.__argument(ttype, tvalue):
  File "~/sievelib/sievelib/parser.py", line 285, in __argument
    self.__curcommand.non_deterministic_args
AttributeError: 'NoneType' object has no attribute 'non_deterministic_args'

Interestingly, if address :domain "" ""){ crashes in master (with the same error), but does not crash in 1.1.1. if address :domain "" "")) crashes with the same error as in 1.1.1. Both versions do not crash with either if address :domain "" ""), if address :domain ""), or if address :domain "" "" "").

from strainer.

derula avatar derula commented on May 27, 2024

Even simpler: } crashes as well. I think the problem is that the parser doesn't properly keep track of parenthesis / bracket depth. It just encounters a close bracket and assumes that it was properly opened. To solve this, we could introduce a stack of opened brackets, and when a close bracket mismatches, it's an instant parse error.

However, this would also mean that during partial lexing, I will have to backtrack to when the bracket was opened...

One solution would be to always use the entire file in partial lexing, but to only change styling between start and end (and wherever the first token starts / last token ends). I will create an issue for this.

My bad, partial lexing doesn't use the parser, only the lexer. Doesn't apply here.

from strainer.

derula avatar derula commented on May 27, 2024

Reopened to implement a workaround since sievelib bug is still open.

from strainer.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.