Skip to content
Permalink
Browse files
fixed #28 - Inconsistent behavior of html_strip
  • Loading branch information
glookka authored and klirichek committed Jul 18, 2017
1 parent 9980277 commit cb991641103f8a3038a70e83b7e539fc63889beb
Showing with 40 additions and 2 deletions.
  1. +22 −1 src/searchd.cpp
  2. +1 −1 test/test_120/model.bin
  3. +17 −0 test/test_120/test.xml
@@ -12713,6 +12713,10 @@ void HandleMysqlInsert ( SqlRowBuffer_c & tOut, const SqlStmt_t & tStmt,

CSphVector<int> dAttrSchema ( tSchema.GetAttrsCount() );
CSphVector<int> dFieldSchema ( tSchema.m_dFields.GetLength() );
CSphVector<bool> dFieldAttrs ( tSchema.m_dFields.GetLength() );
ARRAY_FOREACH ( i, dFieldAttrs )
dFieldAttrs[i] = false;

int iIdIndex = 0;
if ( !tStmt.m_dInsertSchema.GetLength() )
{
@@ -12774,6 +12778,10 @@ void HandleMysqlInsert ( SqlRowBuffer_c & tOut, const SqlStmt_t & tStmt,
break;
}
dFieldSchema[i] = iField;

// does an attribute with the same name exist?
if ( tSchema.GetAttr ( tSchema.m_dFields[i].m_sName.cstr() ) )
dFieldAttrs[i] = true;
} else
dFieldSchema[i] = -1;
}
@@ -12910,6 +12918,12 @@ void HandleMysqlInsert ( SqlRowBuffer_c & tOut, const SqlStmt_t & tStmt,

// convert fields
CSphVector<const char*> dFields;

// if strings and fields share one value, it might be modified by html stripper etc
// we need to use separate storage for such string attributes and fields
CSphVector<CSphString> dTmpFieldStorage;
dTmpFieldStorage.Resize(tSchema.m_dFields.GetLength());

ARRAY_FOREACH ( i, tSchema.m_dFields )
{
int iQuerySchemaIdx = dFieldSchema[i];
@@ -12922,7 +12936,14 @@ void HandleMysqlInsert ( SqlRowBuffer_c & tOut, const SqlStmt_t & tStmt,
sError.SetSprintf ( "row %d, column %d: string expected", 1+c, 1+iQuerySchemaIdx ); // 1 for human base
break;
}
dFields.Add ( tStmt.m_dInsertValues[ iQuerySchemaIdx + c * iExp ].m_sVal.cstr() );

const char * szFieldValue = tStmt.m_dInsertValues[ iQuerySchemaIdx + c * iExp ].m_sVal.cstr();
if ( dFieldAttrs[i] )
{
dTmpFieldStorage[i] = szFieldValue;
dFields.Add ( dTmpFieldStorage[i].cstr() );
} else
dFields.Add ( szFieldValue );
}
}
if ( !sError.IsEmpty() )
@@ -1 +1 @@
a:1:{i:0;a:3:{i:0;a:2:{s:8:"sphinxql";s:43:"select * from test_idx where match( 'div' )";s:10:"total_rows";i:0;}i:1;a:2:{s:8:"sphinxql";s:44:"select * from test_idx where match( 'span' )";s:10:"total_rows";i:0;}i:2;a:3:{s:8:"sphinxql";s:43:"select * from test_idx where match( 'end' )";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:2:{s:2:"id";s:1:"1";s:3:"idd";s:1:"1";}}}}}
a:1:{i:0;a:6:{i:0;a:2:{s:8:"sphinxql";s:43:"select * from test_idx where match( 'div' )";s:10:"total_rows";i:0;}i:1;a:2:{s:8:"sphinxql";s:44:"select * from test_idx where match( 'span' )";s:10:"total_rows";i:0;}i:2;a:3:{s:8:"sphinxql";s:43:"select * from test_idx where match( 'end' )";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:2:{s:2:"id";s:1:"1";s:3:"idd";s:1:"1";}}}i:3;a:2:{s:8:"sphinxql";s:145:"INSERT INTO rt (id, gid, title, body) VALUES (1, 10, '<div><span>That paper also reminds me end point</span></div>cool friend','<div>body</div>')";s:14:"total_affected";i:1;}i:4;a:3:{s:8:"sphinxql";s:16:"select * from rt";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:4:{s:2:"id";s:1:"1";s:3:"gid";s:2:"10";s:5:"title";s:71:"<div><span>That paper also reminds me end point</span></div>cool friend";s:4:"body";s:15:"<div>body</div>";}}}i:5;a:2:{s:8:"sphinxql";s:35:"select * from rt where match('div')";s:10:"total_rows";i:0;}}}
@@ -34,6 +34,19 @@ index test_idx
html_strip = 1
}

index rt
{
type = rt
path = <data_path/>/rt
docinfo = extern
rt_mem_limit = 128k
rt_field = title
rt_attr_string = title
rt_attr_string = body
rt_attr_uint = gid
html_strip = 1
}

</Config>
<DB_Create>
CREATE TABLE test_table
@@ -56,6 +69,10 @@ INSERT INTO `test_table` VALUES
<SPHinxQL>select * from test_idx where match( 'div' )</SPHinxQL>
<SPHinxQL>select * from test_idx where match( 'span' )</SPHinxQL>
<SPHinxQL>select * from test_idx where match( 'end' )</SPHinxQL>

<sphinxql>INSERT INTO rt (id, gid, title, body) VALUES (1, 10, '&lt;div>&lt;span&gt;That paper also reminds me end point&lt;/span&gt;&lt;/div&gt;cool friend','&lt;div&gt;body&lt;/div&gt;')</sphinxql>
<sphinxql>select * from rt</sphinxql>
<sphinxql>select * from rt where match('div')</sphinxql>
</SPHQueries>

</Test>

0 comments on commit cb99164

Please sign in to comment.