Skip to content

[BUG] HTML is modified when saved #593

@line-o

Description

@line-o

Describe the bug

  1. When an html file is opened it is modified before it is displayed.
  2. When an html file is saved it modified before it is saved.

NOTE: This issue is about

  • autoclosing empty tags in HTML that are not allowed to be autoclosing such as <script>
  • swallowing CDATA sections and escaping the enclosed content

Both are likely due to some serialization that takes place.

Expected behavior

A source file is opened and displayed as it is stored within the database.
A source file created or modified in eXide is stored unmodified.

To Reproduce

  1. store a file /db/apps/test/test.html in the database with following contents
    NOTE: you have to use other means than eXide to do that, obviously. Think: WebDav, rest (curl), XML-RPC (xst)
<html>
    <body>
        <main></main>
        <script type="text/javascript"><![CDATA[ console.log(true && 1 < 2) ]]></script>
    </body>
</html>
  1. open the file in eXide and you will get
  • an autoclosed, empty main-element (this is fine for XML but detrimental for HTML)
  • the CDATA section is lost and its contents are now escaped with entities
<html>
    <body>
        <main/>
        <script type="text/javascript"> console.log(true &amp;&amp; 1 &lt; 2) </script>
    </body>
</html>
  1. modify the contents to the original content again and save it
  2. load the contents via WebDav, REST, XML-RPC again (curl http://localhost:8080/exist/rest/db/apps/test/test.html)
  3. the CDATA section was swallowed and its enclosed content escaped with entities
    NOTE: That the file has an XML declaration now might be due to the serialization on retrieval via curl
<?xml version="1.0" encoding="UTF-8"?>
<html>
    <body>
        <main></main>
        <script type="text/javascript"> console.log(true &amp;&amp; 1 &lt; 2) </script>
    </body>
</html>
  1. reloading the file also changes the contents back to what we got at step 2

Integration Test (TODO)

For UI and browser based testing we use cypress.js

// adjust as necessary
describe('The app', function() {
  it('should load', function() {
    // Go to app start page
    cy.visit('/app/index.html')
  })

Context (please always complete the following information):

Build: eXist-6.2.0
Java: 1.8.0_362 (Azul Systems, Inc.)
OS: Mac OS X 12.6.3 (aarch64)
App Version: 3.5.0

Additional context

  • How is eXist-db installed? built from source
  • Any custom changes in e.g. conf.xml? none

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions