Git Product home page Git Product logo

Comments (4)

mibe avatar mibe commented on August 23, 2024

Erm, can you give some code example? I just don't get what you mean?

from feedwriter.

trepmag avatar trepmag commented on August 23, 2024

Oups yes sorry my initial message doesn't contains much infos...

Feed item elements are built using htmlspecialchars():

The choice of using htmlspecialchars() could be leave to developer...

For example, this is an issue with links containing query string parts; e.g.:
$item->setLink('http://example.com/?dont=borgat&that=join&my=friend');
// The above item element content will output a non equivalent link: http://example.com/?dont=borgat&that=join&my=friend

To resolve this I've remove those htmlspecialchars() usages: trepmag@9589f10

from feedwriter.

mibe avatar mibe commented on August 23, 2024

Thank you for your explanation, I get it now.

The problem with the ampersand character is that this is a special character in the XML specification. The spec says:

The ampersand character (&) and the left angle bracket (<) MUST NOT appear in their literal form […]. If they are needed elsewhere, they MUST be escaped using either numeric character references or the strings "&amp;" and "&lt;" respectively.

So without htmlspecialchars() the feed would not validate properly. See the result of W3C's feed validation service here (I've encoded the ampersand in the title, otherwise the service would have stopped there).

But that encoded ampersand shouldn't actually be a problem. The client which parses the XML should turn that back into a real ampersand character. Here's a screenshot of Firefox displaying the URL with encoded ampersands.

But there is a workaround to have valid, unencoded ampersands in the link element: Wrap the link in a CDATA section. To do this call the addCDATAEncoding() method of the Feed class:

$feed->addCDATAEncoding(array('link'));

I hope that helps (and sorry I took so long to reply) 😊

from feedwriter.

trepmag avatar trepmag commented on August 23, 2024

Hello Mibe, this should works perfectly!

Thanks,
Cedric

from feedwriter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.