File: escaping.coffee

package info (click to toggle)
node-xml2js 0.4.23%2B~cs15.4.0%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,380 kB
  • sloc: xml: 117; javascript: 7; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 933 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
suite 'Text Processing', ->
  test 'Escaping element value', ->
    eq(
      xml('root', { headless: true })
        .ele('e', 'escaped <>\'"&\t\n').up()
        .ele('e', 'escaped <>\'"&\t\r\n').up()
        .ele('e', 'escaped <>\'"&\t\n\r').up()
        .ele('e')
          .att('a1', 'escaped <>\'"&\t\n')
          .att('a2', 'escaped <>\'"&\t\r')
          .att('a3', 'escaped <>\'"&\t\n\r')
          .att('a4', 'escaped <>\'"&\t\r\n')
        .up()
      .end()

      '<root>' +
        '<e>escaped &lt;&gt;\'"&amp;\t\n</e>' +
        '<e>escaped &lt;&gt;\'"&amp;\t&#xD;\n</e>' +
        '<e>escaped &lt;&gt;\'"&amp;\t\n&#xD;</e>' +
        '<e' +
          ' a1="escaped &lt;>\'&quot;&amp;&#x9;&#xA;"' +
          ' a2="escaped &lt;>\'&quot;&amp;&#x9;&#xD;"' +
          ' a3="escaped &lt;>\'&quot;&amp;&#x9;&#xA;&#xD;"' +
          ' a4="escaped &lt;>\'&quot;&amp;&#x9;&#xD;&#xA;"' +
        '/>' +
      '</root>'
    )