Here's a better patch that solves this issue properly.
example with this string : <a>b<b>a</b>r</a>
before the first patch, the parser was doing this :
* start when an opening tag with an id attribute is matched
* seeks to the next closing tag, overwriting any previous
grabbed data if there is another opening tag before any
closing tag is found
* stops with the first closing tagthe result was : a
with the first patch I corrected the overwriting problem, but didn't notice the problem with the non-matching closing tag, the result was :
a b
now it's a b c
didou
Mehdi Achour wrote:
Hi,
Attached a patch that allows using entities in the titles collected by mkindex.php. This fix a problem with the french doc where we have this kind of stuff :
<title>Migration &php;</title>
Actually only PHP (the substitution of &php;) is inserted in the database.
didou
------------------------------------------------------------------------
Index: mkindex.php
===================================================================
RCS file: /repository/livedocs/mkindex.php,v
retrieving revision 1.32
diff -u -r1.32 mkindex.php
--- mkindex.php 27 Apr 2004 14:43:28 -0000 1.32
+++ mkindex.php 23 May 2004 06:42:50 -0000
@@ -99,6 +99,7 @@
$this->data .= "INSERT INTO idents VALUES ('{$this->last_id}', {$this->fileid}, '" . sqlite_escape_string(trim($this->cdata)) . "');";
$this->last_id = false;
+ $this->cdata = '';
}
}
@@ -107,7 +108,7 @@
//small hack for '&'
$data = str_replace('||amp||', '&', $data);
- $this->cdata = $data;
+ $this->cdata .= ' ' . trim($data);
}
}
Index: mkindex.php
===================================================================
RCS file: /repository/livedocs/mkindex.php,v
retrieving revision 1.32
diff -u -r1.32 mkindex.php
--- mkindex.php 27 Apr 2004 14:43:28 -0000 1.32
+++ mkindex.php 23 May 2004 07:36:46 -0000
@@ -86,19 +86,27 @@
}
function start_elem($parser, $name, $attrs) {
+ // the previous tag was containing the catched id
+ // so we register the current tag as title delimiter
+ if ($this->last_id !== false && $this->tag_name == '') {
+ $this->tag_name = $name;
+ }
// if there is an ID attribute, record it
if (isset($attrs['ID'])) {
$this->last_id = $attrs['ID'];
+ $this->tag_name = '';
}
}
function end_elem($parser, $name) {
- if ($this->last_id !== false) {
+ if ($this->last_id !== false && $this->tag_name == $name) {
+
echo "\tAdded ID {$this->last_id}\n";
$this->data .= "INSERT INTO idents VALUES ('{$this->last_id}',
{$this->fileid}, '" . sqlite_escape_string(trim($this->cdata)) . "');";
$this->last_id = false;
+ $this->cdata = '';
}
}
@@ -107,7 +115,7 @@
//small hack for '&'
$data = str_replace('||amp||', '&', $data);
- $this->cdata = $data;
+ $this->cdata .= ' ' . trim($data);
}
}
