这是一个奇怪的... 在一个 XML 提要中,通过几行循环在 PHP 中生成,一个 HARDCODED 字符串在一个位置发生了变化。
生成的 XML 文件是 36000 行。在第 8020 行发生了以下情况:
<g:google_product_category>Home & Garden > Decor > Window Treatments > Curtains & Drapes</g:google_product_category>
已更改为(注意:为清楚起见,我在此处添加了星号):
<g:google_product_category>Home & Garden > Decor > Window Treatments **&ggt;** Curtains & Drapes</g:google_product_category>
奇怪的是,这条线不包含任何可能被破坏的变量。这是一个硬编码的字符串 - 见下文。这怎么可能?该行在 XML 文件中出现 751 次。这种情况只发生在一处。
多次运行 XML 生成器时,会发生相同类型的错误,但不是在同一个地方。随机的“html 安全字符”(如 & gt ; & amp ; 将一个字母复制到 & ggt ; 或 & aamp ;
XML 不是作为对象生成的,而是由构建字符串的 for 循环生成的,如下所示:
$ret .= "<item>\n";
$ret .= "<g:id>ft-".$row["entry_id"]."</g:id>\n";
$ret .= "<g:title>".$row["title"]."</g:title>\n";
$ret .= "<g:description>".$row["description"]."</g:description>\n";
$ret .= "<g:link>http://www.example.com/sidor/fototapet/".$row["entry_id"]."?google=true</g:link>\n";
$ret .= "<g:image_link>http://www.example.com/".$this->get_filename($row2["field_id_6"],$row["entry_id"])."</g:image_link>\n";
$ret .= "<g:condition>new</g:condition>\n";
$ret .= "<g:availability>in stock</g:availability>\n";
$ret .= "<g:price>". ceil(280*$price_mod) ."</g:price>\n";
$ret .= "<g:google_product_category>Home & Garden > Decor > Window Treatments > Curtains & Drapes</g:google_product_category>\n";
$ret .= "<g:product_type>Fototapet</g:product_type>\n";
$ret .= "</item>\n";