Commit 0dd3b7e0 authored by Yassine Doghri's avatar Yassine Doghri
Browse files

fix(rss): do not escape podcast and episode titles in the xml

- add parameter to prevent escaping value in SimpleRSSElement's addChild method
- clean prosemirror residue (typedef + DEPENDENCIES.md)
- remove type definition generation in tsconfig

fixes #138, #71
parent 9ec1cb93
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -39,8 +39,6 @@ Javascript dependencies:
  ([MIT License](https://github.com/rollup/rollup/blob/master/LICENSE.md))
- [tailwindcss](https://tailwindcss.com/)
  ([MIT License](https://github.com/tailwindcss/tailwindcss/blob/master/LICENSE))
- [ProseMirror](https://prosemirror.net/)
  ([MIT License](https://github.com/ProseMirror/prosemirror/blob/master/LICENSE))
- [amCharts 4](https://github.com/amcharts/amcharts4)
  ([Free amCharts license](https://github.com/amcharts/amcharts4/blob/master/dist/script/LICENSE))
- [Choices.js](https://joshuajohnson.co.uk/Choices/)
+2 −1
Original line number Diff line number Diff line
@@ -226,7 +226,8 @@ if (! function_exists('form_dropdown')) {
                }
                $form .= "</optgroup>\n";
            } else {
                $form .= '<option value="' . htmlspecialchars($key) . '"'
                /** @noRector RecastingRemovalRector */
                $form .= '<option value="' . htmlspecialchars((string) $key) . '"'
                        . (in_array($key, $selected, true) ? ' selected="selected"' : '') . '>'
                        . $val . "</option>\n";
            }
+3 −3
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ if (! function_exists('get_rss_feed')) {
        $channel->addChild('docs', 'https://cyber.harvard.edu/rss/rss.html');

        $channel->addChild('guid', $podcast->guid, $podcastNamespace);
        $channel->addChild('title', $podcast->title);
        $channel->addChild('title', $podcast->title, null, false);
        $channel->addChildWithCDATA('description', $podcast->description_html);

        $itunesImage = $channel->addChild('image', null, $itunesNamespace);
@@ -189,7 +189,7 @@ if (! function_exists('get_rss_feed')) {

        $image = $channel->addChild('image');
        $image->addChild('url', $podcast->image->feed_url);
        $image->addChild('title', $podcast->title);
        $image->addChild('title', $podcast->title, null, false);
        $image->addChild('link', $podcast->link);

        if ($podcast->custom_rss !== null) {
@@ -200,7 +200,7 @@ if (! function_exists('get_rss_feed')) {

        foreach ($episodes as $episode) {
            $item = $channel->addChild('item');
            $item->addChild('title', $episode->title);
            $item->addChild('title', $episode->title, null, false);
            $enclosure = $item->addChild('enclosure');

            $enclosure->addAttribute(
+21 −5
Original line number Diff line number Diff line
@@ -29,9 +29,13 @@ class SimpleRSSElement extends SimpleXMLElement

        if ($newChild !== null) {
            $node = dom_import_simplexml($newChild);
            if ($node !== null) {
                $no = $node->ownerDocument;
                if ($no !== null) {
                    $node->appendChild($no->createCDATASection($value));
                }
            }
        }

        return $newChild;
    }
@@ -43,17 +47,29 @@ class SimpleRSSElement extends SimpleXMLElement
     * @param string $name — The name of the child element to add.
     * @param string $value — [optional] If specified, the value of the child element.
     * @param string $namespace [optional] If specified, the namespace to which the child element belongs.
     * @param boolean $escape [optional] The value is escaped by default, can be set to false.
     *
     * @return static The addChild method returns a SimpleXMLElement object representing the child added to the XML node.
     */
    public function addChild($name, $value = null, $namespace = null)
    public function addChild($name, $value = null, $namespace = null, $escape = true)
    {
        $newChild = parent::addChild($name, '', $namespace);

        if ($newChild !== null) {
            $node = dom_import_simplexml($newChild);
            if ($node !== null) {
                $no = $node->ownerDocument;
            $node->appendChild($no->createTextNode((string) esc($value)));
                $value = $escape ? esc($value ?? '') : $value ?? '';
                if ($no === null) {
                    return $newChild;
                }
                if (is_array($value)) {
                    return $newChild;
                }
                /** @noRector RecastingRemovalRector */
                $node->appendChild($no->createTextNode((string) $value));
                return $newChild;
            }
        }

        return $newChild;
+0 −2
Original line number Diff line number Diff line
declare module "prosemirror-markdown";
declare module "prosemirror-example-setup";
declare module "leaflet.markercluster";
Loading