<?xml version="1.0"?>
<?xml-stylesheet
href="http://www.w3.org/2000/08/w3c-synd/style.css" type="text/css"
?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel rdf:about="http://pear.php.net/bugs/search.php">
    <title>PEAR Bug Search Results</title>
    <link>http://pear.php.net/bugs/search.php?cmd=display&amp;package_name%5B0%5D=Validate_ES</link>
    <description>Search Results</description>
    <dc:language>en-us</dc:language>
    <dc:creator>pear-webmaster@lists.php.net</dc:creator>
    <dc:publisher>pear-webmaster@lists.php.net</dc:publisher>
    <admin:generatorAgent rdf:resource="http://pear.php.net/bugs"/>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
    <items>
     <rdf:Seq>
      <rdf:li rdf:resource="http://pear.php.net/bug/20526" />

     </rdf:Seq>
    </items>
  </channel>

  <image rdf:about="http://pear.php.net/gifs/pearsmall.gif">
    <title>PEAR Bugs</title>
    <url>http://pear.php.net/gifs/pearsmall.gif</url>
    <link>http://pear.php.net/bugs</link>
  </image>

    <item rdf:about="http://pear.php.net/bug/20526">
      <title>Validate_ES: Bug 20526 [Open] CIF Calculation retrieves wrong array index</title>
      <link>http://pear.php.net/bugs/20526</link>
      <content:encoded><![CDATA[<pre>Validate_ES Bug
Reported by romeurosa
2015-03-25T16:29:22+00:00
PHP: Irrelevant OS: Linux Package Version: Unknown

Description:
------------
Taking into consideration the following valid Spanish CIF ()
This will return 0 from the cif($cif) method found in ES.php.
On closer inspection I verified that when you do the final verification:

if ((int)$controlCode != $d &amp;&amp; $letters2[$d] != $controlCode) {

$letters2[$d] for that cif will return F. This is because the array starts at index 0 and 
not index 1.
If you change that for $letters2[$d-1], or shift all the indexes by 1 it will work.



Test script:
---------------
class ES
{
     function testCIF()
     {
         echo 'Result: ' . (int) $this-&gt;cif('Q5355149E');
     }

     function cif($cif)
     {
         // Same one as in ES.php
     }
}

Expected result:
----------------
Result: 1

Actual result:
--------------
Result: 0</pre>]]></content:encoded>
      <description><![CDATA[<pre>Validate_ES Bug
Reported by romeurosa
2015-03-25T16:29:22+00:00
PHP: Irrelevant OS: Linux Package Version: Unknown

Description:
------------
Taking into consideration the following valid Spanish CIF ()
This will return 0 from the cif($cif) method found in ES.php.
On closer inspection I verified that when you do the final verification:

if ((int)$controlCode != $d &amp;&amp; $letters2[$d] != $controlCode) {

$letters2[$d] for that cif will return F. This is because the array starts at index 0 and 
not index 1.
If you change that for $letters2[$d-1], or shift all the indexes by 1 it will work.



Test script:
---------------
class ES
{
     function testCIF()
     {
         echo 'Result: ' . (int) $this-&gt;cif('Q5355149E');
     }

     function cif($cif)
     {
         // Same one as in ES.php
     }
}

Expected result:
----------------
Result: 1

Actual result:
--------------
Result: 0</pre>]]></description>
      <dc:date>2015-03-25T16:29:22+00:00</dc:date>
      <dc:creator>romeurosa &amp;#x61;&amp;#116; gmail &amp;#x64;&amp;#111;&amp;#x74; com</dc:creator>
      <dc:subject>Validate_ES Bug</dc:subject>
    </item>
</rdf:RDF>
