Skip to content

Commit

Permalink
Escaped <> in attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
ohler55 committed Mar 3, 2018
1 parent 39e36fc commit fda4896
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

## 2.8.3 - March 3, 2018

- Attribute values now escape < and > on dump.

## 2.8.2 - November 1, 2017

- Fixed bug with SAX parser that caused a crash with very long invalid instruction element.
Expand Down
2 changes: 1 addition & 1 deletion ext/ox/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static const char xml_friendly_chars[257] = "\

static const char xml_quote_chars[257] = "\
:::::::::11::1::::::::::::::::::\
11611151111111111111111111111111\
11611151111111111111111111114141\
11111111111111111111111111111111\
11111111111111111111111111111111\
11111111111111111111111111111111\
Expand Down
2 changes: 1 addition & 1 deletion ext/ox/sax_buf.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extern int ox_sax_buf_read(Buf buf);

static inline char
buf_get(Buf buf) {
//printf("*** drive get from '%s' from start: %ld buf: %p from read_end: %ld\n", buf->tail, buf->tail - buf->head, buf->head, buf->read_end - buf->tail);

This comment has been minimized.

Copy link
@tarragon

tarragon Mar 5, 2018

👋 You have left this debugging statement in and this has made ox break quite badly for us (in CI).

This comment has been minimized.

Copy link
@ohler55

ohler55 Mar 5, 2018

Author Owner

sigh, new release in the works

This comment has been minimized.

Copy link
@ohler55

ohler55 Mar 5, 2018

Author Owner

Fixed and released.

printf("*** drive get from '%s' from start: %ld buf: %p from read_end: %ld\n", buf->tail, buf->tail - buf->head, buf->head, buf->read_end - buf->tail);
if (buf->read_end <= buf->tail) {
if (0 != ox_sax_buf_read(buf)) {
return '\0';
Expand Down
2 changes: 1 addition & 1 deletion lib/ox/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

module Ox
# Current version of the module.
VERSION = '2.8.2'
VERSION = '2.8.3'
end
5 changes: 3 additions & 2 deletions test/tests.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
# encoding: UTF-8
# encoding: utf-8

# Ubuntu does not accept arguments to ruby when called using env. To get warnings to show up the -w options is
# required. That can be set in the RUBYOPT environment variable.
Expand Down Expand Up @@ -374,7 +374,8 @@ def test_escape_value
doc = Ox.parse(xml)
assert_equal('<&test>', doc.attributes[:name])
dumped_xml = Ox.dump(doc)
assert_equal(xml, dumped_xml)
escaped_xml = %{\n<top name="&lt;&amp;test&gt;">&lt;not \'quoted\'&gt;</top>\n}
assert_equal(escaped_xml, dumped_xml)
end

def test_escape_bad
Expand Down

0 comments on commit fda4896

Please sign in to comment.