Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7aa1a080a7de
Choose a base ref
...
head repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f9c2e583f9a0
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Sep 27, 2017

  1. Remove XML.escape

    XML::Builder is the preferred way to build XML documents
    asterite committed Sep 27, 2017
    Copy the full SHA
    215bc2e View commit details
  2. Copy the full SHA
    f9c2e58 View commit details
Showing with 0 additions and 26 deletions.
  1. +0 −14 spec/std/xml/xml_spec.cr
  2. +0 −12 src/xml.cr
14 changes: 0 additions & 14 deletions spec/std/xml/xml_spec.cr
Original file line number Diff line number Diff line change
@@ -302,20 +302,6 @@ describe XML do
doc.root.to_s.should eq("<person>\n <name>たろう</name>\n</person>")
end

describe "escape" do
it "does not change a safe string" do
str = XML.escape("safe_string")

str.should eq("safe_string")
end

it "escapes dangerous characters from a string" do
str = XML.escape("< & >")

str.should eq("&lt; &amp; &gt;")
end
end

it "sets an attribute" do
doc = XML.parse(%{<foo />})
root = doc.root.not_nil!
12 changes: 0 additions & 12 deletions src/xml.cr
Original file line number Diff line number Diff line change
@@ -47,18 +47,6 @@
# string # => "<?xml version=\"1.0\"?>\n<person id=\"1\">\n <firstname>Jane</firstname>\n <lastname>Doe</lastname>\n</person>\n"
# ```
module XML
SUBSTITUTIONS = {
'>' => "&gt;",
'<' => "&lt;",
'"' => "&quot;",
'\'' => "&apos;",
'&' => "&amp;",
}

def self.escape(string : String)
string.gsub(SUBSTITUTIONS)
end

# Parses an XML document from *string* with *options* into an `XML::Node`.
#
# See `ParserOptions.default` for default options.