From 40bc27b23d9d2be47f04c9ad0696682d79cf0c57 Mon Sep 17 00:00:00 2001 From: John Fairhurst Date: Wed, 16 May 2018 10:40:40 +0100 Subject: [PATCH] Do not crash with bad declaration XML --- CHANGELOG.md | 4 ++++ lib/jazzy/sourcekitten.rb | 11 +++++++---- spec/integration_specs | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f569455d2..6d99ebf83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ [John Fairhurst](https://github.com/johnfairh) [#965](https://github.com/realm/jazzy/issues/965) +* Fix crash with unicode scalars in string literals. + [John Fairhurst](https://github.com/johnfairh) + [#972](https://github.com/realm/jazzy/issues/972) + ## 0.9.3 ##### Breaking diff --git a/lib/jazzy/sourcekitten.rb b/lib/jazzy/sourcekitten.rb index b4df51c1f..046cfae43 100644 --- a/lib/jazzy/sourcekitten.rb +++ b/lib/jazzy/sourcekitten.rb @@ -339,6 +339,8 @@ def self.make_doc_info(doc, declaration) def self.xml_to_text(xml) document = REXML::Document.new(xml) REXML::XPath.match(document.root, '//text()').map(&:value).join + rescue + '' end # Regexp to match an @attribute. Complex to handle @available(). @@ -372,10 +374,11 @@ def self.split_decl_attributes(declaration) end def self.prefer_parsed_decl?(parsed, annotated) - parsed && - (annotated.include?(' = default') || # SR-2608 - parsed.match('@autoclosure|@escaping') || # SR-6321 - parsed.include?("\n")) + annotated.empty? || + parsed && + (annotated.include?(' = default') || # SR-2608 + parsed.match('@autoclosure|@escaping') || # SR-6321 + parsed.include?("\n")) end # Replace the fully qualified name of a type with its base name diff --git a/spec/integration_specs b/spec/integration_specs index a4ee0bed7..bd5733e0a 160000 --- a/spec/integration_specs +++ b/spec/integration_specs @@ -1 +1 @@ -Subproject commit a4ee0bed7c5c1f4b6ed37e5e584113a876d50ce6 +Subproject commit bd5733e0a0673e611b5b45ddd245a19275bf06b0