Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/twine.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/twine/formatters/android.rb')
-rw-r--r--lib/twine/formatters/android.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/twine/formatters/android.rb b/lib/twine/formatters/android.rb
index ced90b7..55c735c 100644
--- a/lib/twine/formatters/android.rb
+++ b/lib/twine/formatters/android.rb
@@ -116,10 +116,15 @@ module Twine
value = gsub_unless(value, "'", "\\'") { |substring| substring =~ inside_cdata }
value = gsub_unless(value, /&/, '&') { |substring| substring =~ inside_cdata || substring =~ inside_opening_anchor_tag }
- # escape opening angle brackes unless it's a supported styling tag
+ # if `value` contains a placeholder, escape all angle brackets
+ # if not, escape opening angle brackes unless it's a supported styling tag
# https://github.com/scelis/twine/issues/212
# https://stackoverflow.com/questions/3235131/#18199543
- angle_bracket = /<(?!(\/?(b|u|i|a|\!\[CDATA)))/ # matches all `<` but <b>, <u>, <i>, <a> and <![CDATA
+ if number_of_twine_placeholders(value) > 0
+ angle_bracket = /<(?!(\/?(\!\[CDATA)))/ # matches all `<` but <![CDATA
+ else
+ angle_bracket = /<(?!(\/?(b|u|i|a|\!\[CDATA)))/ # matches all `<` but <b>, <u>, <i>, <a> and <![CDATA
+ end
value = gsub_unless(value, angle_bracket, '&lt;') { |substring| substring =~ inside_cdata }
# escape non resource identifier @ signs (http://developer.android.com/guide/topics/resources/accessing-resources.html#ResourcesFromXml)