[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    Re: Review Request 111754: syntax highlighter must deal more robustly with infinite loops
From:       "Bruno Vasselle" <bruno.vasselle () laposte ! net>
Date:       2013-12-26 19:08:03
Message-ID: 20131226190803.27906.45975 () probe ! kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/111754/
-----------------------------------------------------------

(Updated Dec. 26, 2013, 7:08 p.m.)


Status
------

This change has been marked as submitted.


Review request for Kate, Christoph Cullmann, Dominik Haumann, and Milian Wolff.


Repository: kate


Description
-------

The syntax highlighter currently has some kind of protection against infinite loops induced by buggy \
highlighting XML. Resolution of bug 144599 is an example of such a protection.

However, with such concepts as "lookAhead", which basically matches null strings, the risk of infinite \
loops cannot be sanely guaranteed by ad-hoc patches produced on an on-bug basis, but rather requires a \
framework that per se offers such a guaranty.

The patch proposes an implementation for this. It registers the current state, in terms of offset within \
the line coupled with context so that it is able to branch to "no match" when it encounters the same \
situation twice. The "no match" branch in turn does not loop on an already encountered context, but \
rather leads to the default path, which increments the offset.

The patch is a few lines long, but requires indentation, which leads to white space noise.

Test XML and text are included for the specific case of some infinite loops not dealt until now.


Diffs
-----

  part/syntax/katehighlight.cpp f44f74e 
  tests/data/syntax/infinite.txt PRE-CREATION 
  tests/data/syntax/infinite.xml PRE-CREATION 

Diff: https://git.reviewboard.kde.org/r/111754/diff/


Testing
-------

Opened randomly files with different syntaxes. Opened specifically infinite.xml with XML highlighter, and \
infinite.txt with infinite.xml highlighter. 

infinite.txt with infinite.xml highlighter falls into infinite loop without the patch.


Thanks,

Bruno Vasselle


[Attachment #5 (text/html)]

<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://git.reviewboard.kde.org/r/111754/">https://git.reviewboard.kde.org/r/111754/</a>
     </td>
    </tr>
   </table>
   <br />



<table bgcolor="#e0e0e0" width="100%" cellpadding="8" style="border: 1px gray solid;">
 <tr>
  <td>
   <h1 style="margin-right: 0.2em; padding: 0; font-size: 10pt;">This change has been marked as \
submitted.</h1>  </td>
 </tr>
</table>
<br />


<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: \
url('https://git.reviewboard.kde.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black solid;">  <tr>
  <td>

<div>Review request for Kate, Christoph Cullmann, Dominik Haumann, and Milian Wolff.</div>
<div>By Bruno Vasselle.</div>


<p style="color: grey;"><i>Updated Dec. 26, 2013, 7:08 p.m.</i></p>









<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
kate
</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid \
#b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">The syntax highlighter currently has some \
kind of protection against infinite loops induced by buggy highlighting XML. Resolution of bug 144599 is \
an example of such a protection.

However, with such concepts as &quot;lookAhead&quot;, which basically matches null strings, the risk of \
infinite loops cannot be sanely guaranteed by ad-hoc patches produced on an on-bug basis, but rather \
requires a framework that per se offers such a guaranty.

The patch proposes an implementation for this. It registers the current state, in terms of offset within \
the line coupled with context so that it is able to branch to &quot;no match&quot; when it encounters the \
same situation twice. The &quot;no match&quot; branch in turn does not loop on an already encountered \
context, but rather leads to the default path, which increments the offset.

The patch is a few lines long, but requires indentation, which leads to white space noise.

Test XML and text are included for the specific case of some infinite loops not dealt until now.
</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Opened randomly files with different \
syntaxes. Opened specifically infinite.xml with XML highlighter, and infinite.txt with infinite.xml \
highlighter. 

infinite.txt with infinite.xml highlighter falls into infinite loop without the patch.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>part/syntax/katehighlight.cpp <span style="color: grey">(f44f74e)</span></li>

 <li>tests/data/syntax/infinite.txt <span style="color: grey">(PRE-CREATION)</span></li>

 <li>tests/data/syntax/infinite.xml <span style="color: grey">(PRE-CREATION)</span></li>

</ul>

<p><a href="https://git.reviewboard.kde.org/r/111754/diff/" style="margin-left: 3em;">View Diff</a></p>







  </td>
 </tr>
</table>




  </div>
 </body>
</html>



_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic