diff options
| author | 2022-09-09 22:56:34 +0200 | |
|---|---|---|
| committer | 2022-09-09 22:56:34 +0200 | |
| commit | 0c472402f22816daa66982a815febc464c4856c8 (patch) | |
| tree | 6bae9004580a5e2106f35f2d9432b405f1bceacc /lib | |
| parent | adf1c3bd9a2feb02227b5468bc0559deb34b60bf (diff) | |
Workaround invalid OPMLs (#4591)
* Workaround invalid OPMLs
#fix https://github.com/FreshRSS/FreshRSS/issues/4590
Accept OPML files lacking text attributes
* Tolerate missing head element
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/lib_opml.php | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/lib_opml.php b/lib/lib_opml.php index 86847d720..f86d780b7 100644 --- a/lib/lib_opml.php +++ b/lib/lib_opml.php @@ -189,16 +189,17 @@ function libopml_parse_string($xml, $strict = true) { 'body' => array() ); - // First, we get all "head" elements. Head is required but its sub-elements - // are optional. - foreach ($opml->head->children() as $key => $value) { - if (in_array($key, unserialize(HEAD_ELEMENTS), true)) { - $array['head'][$key] = (string)$value; - } elseif ($strict) { - throw new LibOPML_Exception( - $key . ' is not part of the OPML 2.0 specification' - ); + if (isset($opml->head)) { + // We get all "head" elements. Head is required but its sub-elements are optional. + foreach ($opml->head->children() as $key => $value) { + if (in_array($key, unserialize(HEAD_ELEMENTS), true)) { + $array['head'][$key] = (string)$value; + } elseif ($strict) { + throw new LibOPML_Exception($key . ' is not part of the OPML 2.0 specification'); + } } + } elseif ($strict) { + throw new LibOPML_Exception('Required OPML head element is missing!'); } // Then, we get body oulines. Body must contain at least one outline |
