Home Download Buy Blog Forum Support

tmLanguage - RegEx crash

tmLanguage - RegEx crash

Postby Jarry Dark on Thu Oct 08, 2009 12:52 pm

Hi,

I've just started evaluating Sublime, looking to move out from e, and I've found a problem when transferring tmLanguage I made there.
It seems that positive/negative lookahead/lookbehind when used in this way crashes Sublime:

Code: Select all
<key>eztpl</key>
<dict>
   <key>patterns</key>
   <array>
      <dict>
         <key>begin</key>
         <string>(?={)</string>
         <key>name</key>
         <string>source.eztpl.embedded.html</string>
         <key>patterns</key>
         <array>
            <dict>
               <key>include</key>
               <string>source.eztpl</string>
            </dict>
         </array>
         <key>end</key>
         <string>(?&lt;=})</string>
      </dict>
   </array>
</dict>
Jarry Dark
 
Posts: 8
Joined: Thu Oct 08, 2009 12:45 pm

Re: tmLanguage - RegEx crash

Postby jps on Thu Oct 08, 2009 2:02 pm

Could you send me the full .tmLanguage you're using that's causing the crash?
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: tmLanguage - RegEx crash

Postby Jarry Dark on Thu Oct 08, 2009 2:30 pm

Here it is, it is actually standard HTML.tmLanguage modified to work with eZ template.tmLanguage.
Just try to enter curly brackets in some eZ template file (or just plain HTML file) and down it goes.
Attachments
html_ezp.zip
(4.56 KiB) Downloaded 179 times
Jarry Dark
 
Posts: 8
Joined: Thu Oct 08, 2009 12:45 pm

Re: tmLanguage - RegEx crash

Postby jps on Fri Oct 09, 2009 10:39 am

As you mention, then excerpt you posted is indeed making Sublime Text unhappy: the regex (?={) doesn't consume any characters, which in-and-of-itself doesn't cause any issues, however patterns available after matching (?={) is everything in source.eztpl, which in turn includes everything in text.html.basic, which means the pattern (?={) is again available for matching. It's sitting there recursively matching (?={) in an infinite loop.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: tmLanguage - RegEx crash

Postby Jarry Dark on Fri Oct 09, 2009 12:45 pm

You are right, I'm at fault. It seems that e has some logic to resolve the loop, because this combination is working there.
I'll try to rework that definition.

Thanks for looking it up.
Jarry Dark
 
Posts: 8
Joined: Thu Oct 08, 2009 12:45 pm

Re: tmLanguage - RegEx crash

Postby jps on Fri Oct 09, 2009 12:58 pm

There's a good argument that Sublime Text should also prevent this to some degree, such as not matching the same rule twice in a row if the rule doesn't consume any text. I've put this on the todo list, but I'm not sure how quickly it's going to get done.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 26 guests