Bug 57526 - infinite loop when deleting closing tag
Summary: infinite loop when deleting closing tag
Status: RESOLVED FIXED
Alias: None
Product: quanta
Classification: Miscellaneous
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR crash
Target Milestone: ---
Assignee: András Manţia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-21 23:29 UTC by mrudolf
Modified: 2003-04-24 22:02 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mrudolf 2003-04-21 23:29:44 UTC
Version:            (using KDE KDE 3.1.1a)
OS:          Linux

For some files Quanta enters infinite loop when closing tag is deleted.
For example it happens for file http://knowit.sourceforge.net/index.html when
<sup> is entered inside <h2> (for example before "th" in "22th") and then auto-added
</sup> is deleted.

Four checkboxes in Quanta configuration/tag styles are set as follows: off, on, on, off.
Comment 1 András Manţia 2003-04-24 16:17:01 UTC
Subject: quanta/quanta/parser

CVS commit by amantia: 

Fix a parsing and tag autoclosing bug. It may also fix #57526. Can you please try and report success/failure?

CCMAIL: 57526@bugs.kde.org
CCMAIL: quanta-devel@kde.org


  M +12 -3     parser.cpp   1.70
  M +9 -4      tag.cpp   1.24
  M +1 -0      tag.h   1.23


--- quanta/quanta/parser/parser.cpp  #1.69:1.70
@@ -326,4 +326,5 @@ Node *Parser::parseArea(int startLine, i
       tag->type = Tag::XmlTag;
       tag->dtd = m_dtd;
+      tag->validXMLTag = (openNum == 0);
       tag->single = QuantaCommon::isSingleTag(m_dtd->name, tag->name);
       if (tag->name[0] == '/')
@@ -1203,5 +1204,12 @@ Node *Parser::nodeAt(int line, int col, 
   }
 
-  if (findDeepest && node && node->tag->type == Tag::Empty)
+  bc = ec = el = bl = 0;
+  if (node)
+  {
+    node->tag->beginPos(bl, bc);
+    node->tag->endPos(el, ec);
+  }
+  if (node && node->tag->type == Tag::Empty &&
+     (findDeepest || (bl == el && ec < bc)) )
   {
      if (node->parent)
@@ -1260,5 +1268,6 @@ Node *Parser::rebuild(Document *w)
      if ( tagStr != text ||
           node->tag->type == Tag::Empty ||
-          node->insideSpecial
+          node->insideSpecial ||
+          node->tag->validXMLTag == false
         )
      {
@@ -1282,5 +1291,5 @@ Node *Parser::rebuild(Document *w)
         text = w->text(bl + lineDiff, bc, el + lineDiff, ec);
         tagStr = node->tag->tagStr();
-        if (tagStr == text && node->tag->type != Tag::Empty && !node->insideSpecial)
+        if (tagStr == text && node->tag->type != Tag::Empty && !node->insideSpecial && !node->tag->validXMLTag)
         {
           if (!lastNode)

--- quanta/quanta/parser/tag.cpp  #1.23:1.24
@@ -36,4 +36,5 @@ Tag::Tag()
   m_nameLine = -1;
   m_nameCol = -1;
+  validXMLTag = true;
 }
 
@@ -148,11 +149,13 @@ void Tag::parse(const QString &p_tagStr,
  int line = beginLine;
  int col = beginCol;
- if ( ( beginLine == endLine && col < endCol) ||
-      ( beginLine != endLine) )
-     col++;
  int begin;
 
  QString textLine = m_write->editIf->textLine(line);
 
+ if ( textLine[col] == '<' &&
+      (( beginLine == endLine && col < endCol) ||
+       ( beginLine != endLine)) )
+     col++;
+
  while ( (textLine[col].isSpace() || textLine[col] == '>') &&
          !textLine[col].isNull() &&
@@ -176,5 +179,7 @@ void Tag::parse(const QString &p_tagStr,
    col++;
  }
- name = textLine.mid(begin, col-begin);
+ if (beginLine == endLine && col == endCol && textLine[col] != '>')
+    col++;
+ name = textLine.mid(begin, col - begin);
  if (!name.isEmpty())
     m_nameCol = begin;

--- quanta/quanta/parser/tag.h  #1.22:1.23
@@ -132,4 +132,5 @@ public:
   DTDStruct* dtd; //the tag belongs to this DTD
   QString structBeginStr; //if it's a special block, contains the block beginning definition string (like <? or <style language="foo">)
+  bool validXMLTag; //false if the closing ">" was not found
 
 private:


Comment 2 mrudolf 2003-04-24 18:19:27 UTC
Subject: Re:  infinite loop when deleting closing tag

W czwartek, 24 kwietnia 2003 16:17, Mantia Andras napisa
Comment 3 András Manţia 2003-04-24 22:02:10 UTC
Subject: Re:  infinite loop when deleting closing tag

My last commit fixed this bug.

Andras