Projet

Général

Profil

Révision 0b4524f6

Ajouté par Assos Assos il y a presque 9 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/feeds_xpathparser/FeedsXPathParserXML.inc
11 11
class FeedsXPathParserXML extends FeedsXPathParserBase {
12 12

  
13 13
  /**
14
   * Implements FeedsXPathParserBase::setup().
14
   * {@inheritdoc}
15 15
   */
16 16
  protected function setup($source_config, FeedsFetcherResult $fetcher_result) {
17

  
18 17
    if (!empty($source_config['exp']['tidy']) && extension_loaded('tidy')) {
19 18
      $config = array(
20 19
        'input-xml' => TRUE,
......
23 22
      );
24 23
      // Default tidy encoding is UTF8.
25 24
      $encoding = $source_config['exp']['tidy_encoding'];
26
      $raw = tidy_repair_string(trim($fetcher_result->getRaw()), $config, $encoding);
25
      $raw = tidy_repair_string($fetcher_result->getRaw(), $config, $encoding);
27 26
    }
28 27
    else {
29 28
      $raw = $fetcher_result->getRaw();
30 29
    }
31
    $doc = new DOMDocument();
30

  
31
    $options = LIBXML_NONET;
32
    $options |= defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0;
33
    $options |= defined('LIBXML_PARSEHUGE') ? LIBXML_PARSEHUGE : 0;
34

  
35
    $document = new DOMDocument();
36
    $document->strictErrorChecking = FALSE;
37
    $document->recover = TRUE;
38

  
32 39
    $use = $this->errorStart();
33
    $success = $doc->loadXML($raw);
34
    unset($raw);
40

  
41
    $success = $document->loadXML($raw, $options);
42

  
35 43
    $this->errorStop($use, $source_config['exp']['errors']);
44

  
36 45
    if (!$success) {
37 46
      throw new Exception(t('There was an error parsing the XML document.'));
38 47
    }
39
    return $doc;
48

  
49
    return $document;
40 50
  }
41 51

  
52
  /**
53
   * {@inheritdoc}
54
   */
42 55
  protected function getRaw(DOMNode $node) {
43 56
    return $this->doc->saveXML($node);
44 57
  }
58

  
45 59
}

Formats disponibles : Unified diff