Git Product home page Git Product logo

Comments (6)

Progi1984 avatar Progi1984 commented on May 8, 2024

htmlspecialchars change (&, ', ", <, >) by theirs HTML equivalents.

After having inserted some texts in a DOCX file, i confirm the need of use of htmlspecialchars :

<w:p>
  <w:pPr>
    <w:pStyle w:val="style0"/>
    <w:rPr><w:rFonts w:cs="Mangal" w:eastAsia="SimSun"/></w:rPr>
  </w:pPr>
  <w:r>
    <w:rPr></w:rPr>
    <w:t>Texte&amp;Texte</w:t>
  </w:r>
  <w:r>
    <w:rPr></w:rPr>
    <w:t>&apos;Texte</w:t>
  </w:r>
  <w:r>
    <w:rPr></w:rPr>
    <w:t>&quot;</w:t>
  </w:r>
  <w:r>
    <w:rPr></w:rPr>
    <w:t>Texte&lt;Texte&gt;Texte</w:t>
  </w:r>
</w:p>

from phpword.

Progi1984 avatar Progi1984 commented on May 8, 2024

Fixed in develop branch

from phpword.

jdespatis avatar jdespatis commented on May 8, 2024

I've tested this with last dev-master (38d3d7b), it works like a charm

Thanks!

from phpword.

 avatar commented on May 8, 2024

Guys, I wouldn't agree with you.

First, as for me, I escape data before exporting it in any format (HTML, OOXML, no matter). Second time escaping brokes my data.

Second, there are already tons of libraries which offer escaping functionality (e.g. Zend/Escaper). And they are pretty good. Data escaping is much more than single htmlspecialchars call which we have here.

As regards escaping strategy. Output should be escaped and everybody knows this. Escaping should be performed after all data transformations. It's a well-known rule too. PhpWord is a library which helps to build OOXML (and other) documents, based on the provided data. It doesn't change the data, it just packs the data into another format. There are also libraries which help to build HTML pages. So, if we escape data before submitting to HTML builders, why not to escape data before submitting to PhpWord? I don't see any difference here. And my applications goes this way. I can support tons of different formats and escape only once and in one place. Morever, there is no need to implement the same escaping functionality in all libraries for all formats of documents. Just escape data out of the library. Remember: escape once, use multiple times. :)

So, I'm gonna to remove the htmlentities call. Any objections?

from phpword.

 avatar commented on May 8, 2024

New escaping functionality will be considered in scope of #483.

from phpword.

bruce1237 avatar bruce1237 commented on May 8, 2024

thanks, i was strangled with < as well, thanks

from phpword.

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.