rho-tau-extensions 6.2.0 → 7.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/libs/crosswalk/ext/platform/android/Rakefile +19 -1
  3. data/libs/enterprise-barcode/ext/platform/android/adds/lib/aarch64/liballbarcode.a +0 -0
  4. data/libs/enterprise-barcode/ext/platform/android/adds/lib/armeabi/liballbarcode.a +0 -0
  5. data/libs/enterprise-barcode/ext/platform/android/adds/lib/x86/liballbarcode.a +0 -0
  6. data/libs/enterprise-barcode/ext/platform/android/allbarcode.jar +0 -0
  7. data/libs/fcm-push-18/ext.yml +20 -0
  8. data/libs/fcm-push-18/ext/android/AndroidManifest.rb +10 -0
  9. data/libs/fcm-push-18/ext/android/ApplicationManifestAdds.erb +39 -0
  10. data/libs/fcm-push-18/ext/android/Rakefile +187 -0
  11. data/libs/fcm-push-18/ext/android/ext_java.files +3 -0
  12. data/libs/fcm-push-18/ext/android/ext_native.files +1 -0
  13. data/libs/fcm-push-18/ext/android/jni/src/fcmpushclient.cpp +215 -0
  14. data/libs/fcm-push-18/ext/android/jni/src/fcmpushclient.h +74 -0
  15. data/libs/fcm-push-18/ext/android/res/res/values/fireBaseValues.xml +5 -0
  16. data/libs/fcm-push-18/ext/android/src/com/rhomobile/rhodes/fcm/FCMFacade.java +164 -0
  17. data/libs/fcm-push-18/ext/android/src/com/rhomobile/rhodes/fcm/FCMIntentService.java +219 -0
  18. data/libs/fcm-push-18/ext/android/src/com/rhomobile/rhodes/fcm/FCMListener.java +88 -0
  19. data/libs/fcm-push-18/ext/build +16 -0
  20. data/libs/fcm-push-18/ext/build.bat +8 -0
  21. data/libs/fcm-push-18/ext/fcm.xml +9 -0
  22. data/libs/fcm-push-18/ext/iphone/ApplePush_Prefix.pch +7 -0
  23. data/libs/fcm-push-18/ext/iphone/Firebase.h +68 -0
  24. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/FirebaseAnalytics +0 -0
  25. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalytics+AppDelegate.h +62 -0
  26. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalytics.h +115 -0
  27. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalyticsConfiguration.h +1 -0
  28. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalyticsSwiftNameSupport.h +13 -0
  29. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRApp.h +1 -0
  30. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRConfiguration.h +1 -0
  31. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIREventNames.h +389 -0
  32. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIROptions.h +1 -0
  33. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRParameterNames.h +485 -0
  34. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRUserPropertyNames.h +15 -0
  35. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FirebaseAnalytics.h +10 -0
  36. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Modules/module.modulemap +10 -0
  37. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/FirebaseCore +0 -0
  38. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Headers/FIRAnalyticsConfiguration.h +52 -0
  39. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Headers/FIRApp.h +130 -0
  40. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Headers/FIRConfiguration.h +78 -0
  41. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Headers/FIRLoggerLevel.h +35 -0
  42. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Headers/FIROptions.h +133 -0
  43. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Headers/FirebaseCore.h +5 -0
  44. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Modules/module.modulemap +7 -0
  45. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCoreDiagnostics.framework/FirebaseCoreDiagnostics +0 -0
  46. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCoreDiagnostics.framework/Modules/module.modulemap +6 -0
  47. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseInstanceID.framework/FirebaseInstanceID +0 -0
  48. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseInstanceID.framework/Headers/FIRInstanceID.h +276 -0
  49. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseInstanceID.framework/Headers/FirebaseInstanceID.h +1 -0
  50. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseInstanceID.framework/Modules/module.modulemap +7 -0
  51. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseMessaging.framework/FirebaseMessaging +0 -0
  52. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseMessaging.framework/Headers/FIRMessaging.h +508 -0
  53. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseMessaging.framework/Headers/FirebaseMessaging.h +1 -0
  54. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseMessaging.framework/Modules/module.modulemap +8 -0
  55. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseNanoPB.framework/FirebaseNanoPB +0 -0
  56. data/libs/fcm-push-18/ext/iphone/Frameworks/GoogleToolboxForMac.framework/GoogleToolboxForMac +0 -0
  57. data/libs/fcm-push-18/ext/iphone/Frameworks/GoogleToolboxForMac.framework/Modules/module.modulemap +5 -0
  58. data/libs/fcm-push-18/ext/iphone/Frameworks/Protobuf.framework/Modules/module.modulemap +5 -0
  59. data/libs/fcm-push-18/ext/iphone/Frameworks/Protobuf.framework/Protobuf +0 -0
  60. data/libs/fcm-push-18/ext/iphone/Frameworks/nanopb.framework/Modules/module.modulemap +5 -0
  61. data/libs/fcm-push-18/ext/iphone/Frameworks/nanopb.framework/nanopb +0 -0
  62. data/libs/fcm-push-18/ext/iphone/Rakefile +81 -0
  63. data/libs/fcm-push-18/ext/iphone/fcm-push.xcodeproj/project.pbxproj +370 -0
  64. data/libs/fcm-push-18/ext/iphone/impl/PushNotificationsReceiver.h +28 -0
  65. data/libs/fcm-push-18/ext/iphone/impl/PushNotificationsReceiver.m +27 -0
  66. data/libs/fcm-push-18/ext/iphone/impl/PushNotificationsReceiver.mm +234 -0
  67. data/libs/fcm-push-18/ext/iphone/impl/applePushSetup.c +10 -0
  68. data/libs/fcm-push-18/ext/iphone/impl/applepushclient.h +69 -0
  69. data/libs/fcm-push-18/ext/iphone/impl/applepushclient.mm +164 -0
  70. data/libs/fcm-push-18/ext/iphone/impl/readme.txt +7 -0
  71. data/libs/fcm-push-18/ext/platform/iphone/impl/readme.txt +7 -0
  72. data/libs/nodejs/ext/platform/android/jxCore/jx.h +17 -1
  73. data/libs/nodejs/ext/platform/android/jxCore/libcares_arm.a +0 -0
  74. data/libs/nodejs/ext/platform/android/jxCore/libcares_ia32.a +0 -0
  75. data/libs/nodejs/ext/platform/android/jxCore/libcares_x64.a +0 -0
  76. data/libs/nodejs/ext/platform/android/jxCore/libchrome_zlib_arm.a +0 -0
  77. data/libs/nodejs/ext/platform/android/jxCore/libchrome_zlib_ia32.a +0 -0
  78. data/libs/nodejs/ext/platform/android/jxCore/libchrome_zlib_x64.a +0 -0
  79. data/libs/nodejs/ext/platform/android/jxCore/libhttp_parser_arm.a +0 -0
  80. data/libs/nodejs/ext/platform/android/jxCore/libhttp_parser_ia32.a +0 -0
  81. data/libs/nodejs/ext/platform/android/jxCore/libhttp_parser_x64.a +0 -0
  82. data/libs/nodejs/ext/platform/android/jxCore/libjx_arm.a +0 -0
  83. data/libs/nodejs/ext/platform/android/jxCore/libjx_ia32.a +0 -0
  84. data/libs/nodejs/ext/platform/android/jxCore/libjx_x64.a +0 -0
  85. data/libs/nodejs/ext/platform/android/jxCore/libopenssl_arm.a +0 -0
  86. data/libs/nodejs/ext/platform/android/jxCore/libopenssl_ia32.a +0 -0
  87. data/libs/nodejs/ext/platform/android/jxCore/libopenssl_x64.a +0 -0
  88. data/libs/nodejs/ext/platform/android/jxCore/libsqlite3_arm.a +0 -0
  89. data/libs/nodejs/ext/platform/android/jxCore/libsqlite3_ia32.a +0 -0
  90. data/libs/nodejs/ext/platform/android/jxCore/libsqlite3_x64.a +0 -0
  91. data/libs/nodejs/ext/platform/android/jxCore/libuv_arm.a +0 -0
  92. data/libs/nodejs/ext/platform/android/jxCore/libuv_ia32.a +0 -0
  93. data/libs/nodejs/ext/platform/android/jxCore/libuv_x64.a +0 -0
  94. data/libs/nodejs/ext/platform/android/jxCore/libv8_base_arm.a +0 -0
  95. data/libs/nodejs/ext/platform/android/jxCore/libv8_base_ia32.a +0 -0
  96. data/libs/nodejs/ext/platform/android/jxCore/libv8_base_x64.a +0 -0
  97. data/libs/nodejs/ext/platform/android/jxCore/libv8_nosnapshot_arm.a +0 -0
  98. data/libs/nodejs/ext/platform/android/jxCore/libv8_nosnapshot_ia32.a +0 -0
  99. data/libs/nodejs/ext/platform/android/jxCore/libv8_nosnapshot_x64.a +0 -0
  100. data/libs/nodejs/ext/platform/iphone/jxCore/jx.h +17 -1
  101. data/libs/nodejs/ext/platform/iphone/jxCore/libcares.a +0 -0
  102. data/libs/nodejs/ext/platform/iphone/jxCore/libchrome_zlib.a +0 -0
  103. data/libs/nodejs/ext/platform/iphone/jxCore/libhttp_parser.a +0 -0
  104. data/libs/nodejs/ext/platform/iphone/jxCore/libjx.a +0 -0
  105. data/libs/nodejs/ext/platform/iphone/jxCore/libmozjs.a +0 -0
  106. data/libs/nodejs/ext/platform/iphone/jxCore/libopenssl.a +0 -0
  107. data/libs/nodejs/ext/platform/iphone/jxCore/libsqlite3.a +0 -0
  108. data/libs/nodejs/ext/platform/iphone/jxCore/libuv.a +0 -0
  109. data/libs/rexml-edge/rexml/attlistdecl.rb +63 -0
  110. data/libs/rexml-edge/rexml/attribute.rb +192 -0
  111. data/libs/rexml-edge/rexml/cdata.rb +68 -0
  112. data/libs/rexml-edge/rexml/child.rb +97 -0
  113. data/libs/rexml-edge/rexml/comment.rb +80 -0
  114. data/libs/rexml-edge/rexml/doctype.rb +270 -0
  115. data/libs/rexml-edge/rexml/document.rb +291 -0
  116. data/libs/rexml-edge/rexml/dtd/attlistdecl.rb +11 -0
  117. data/libs/rexml-edge/rexml/dtd/dtd.rb +47 -0
  118. data/libs/rexml-edge/rexml/dtd/elementdecl.rb +18 -0
  119. data/libs/rexml-edge/rexml/dtd/entitydecl.rb +57 -0
  120. data/libs/rexml-edge/rexml/dtd/notationdecl.rb +40 -0
  121. data/libs/rexml-edge/rexml/element.rb +1241 -0
  122. data/libs/rexml-edge/rexml/encoding.rb +51 -0
  123. data/libs/rexml-edge/rexml/entity.rb +174 -0
  124. data/libs/rexml-edge/rexml/formatters/default.rb +112 -0
  125. data/libs/rexml-edge/rexml/formatters/pretty.rb +142 -0
  126. data/libs/rexml-edge/rexml/formatters/transitive.rb +58 -0
  127. data/libs/rexml-edge/rexml/functions.rb +418 -0
  128. data/libs/rexml-edge/rexml/instruction.rb +71 -0
  129. data/libs/rexml-edge/rexml/light/node.rb +196 -0
  130. data/libs/rexml-edge/rexml/namespace.rb +48 -0
  131. data/libs/rexml-edge/rexml/node.rb +76 -0
  132. data/libs/rexml-edge/rexml/output.rb +30 -0
  133. data/libs/rexml-edge/rexml/parent.rb +166 -0
  134. data/libs/rexml-edge/rexml/parseexception.rb +52 -0
  135. data/libs/rexml-edge/rexml/parsers/baseparser.rb +533 -0
  136. data/libs/rexml-edge/rexml/parsers/lightparser.rb +59 -0
  137. data/libs/rexml-edge/rexml/parsers/pullparser.rb +197 -0
  138. data/libs/rexml-edge/rexml/parsers/sax2parser.rb +273 -0
  139. data/libs/rexml-edge/rexml/parsers/streamparser.rb +61 -0
  140. data/libs/rexml-edge/rexml/parsers/treeparser.rb +101 -0
  141. data/libs/rexml-edge/rexml/parsers/ultralightparser.rb +57 -0
  142. data/libs/rexml-edge/rexml/parsers/xpathparser.rb +657 -0
  143. data/libs/rexml-edge/rexml/quickpath.rb +266 -0
  144. data/libs/rexml-edge/rexml/rexml.rb +32 -0
  145. data/libs/rexml-edge/rexml/sax2listener.rb +98 -0
  146. data/libs/rexml-edge/rexml/security.rb +28 -0
  147. data/libs/rexml-edge/rexml/source.rb +297 -0
  148. data/libs/rexml-edge/rexml/streamlistener.rb +93 -0
  149. data/libs/rexml-edge/rexml/syncenumerator.rb +33 -0
  150. data/libs/rexml-edge/rexml/text.rb +426 -0
  151. data/libs/rexml-edge/rexml/undefinednamespaceexception.rb +9 -0
  152. data/libs/rexml-edge/rexml/validation/relaxng.rb +539 -0
  153. data/libs/rexml-edge/rexml/validation/validation.rb +144 -0
  154. data/libs/rexml-edge/rexml/validation/validationexception.rb +10 -0
  155. data/libs/rexml-edge/rexml/xmldecl.rb +116 -0
  156. data/libs/rexml-edge/rexml/xmltokens.rb +85 -0
  157. data/libs/rexml-edge/rexml/xpath.rb +81 -0
  158. data/libs/rexml-edge/rexml/xpath_parser.rb +704 -0
  159. data/version +1 -1
  160. metadata +118 -2
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: false
2
+ module REXML
3
+ # A template for stream parser listeners.
4
+ # Note that the declarations (attlistdecl, elementdecl, etc) are trivially
5
+ # processed; REXML doesn't yet handle doctype entity declarations, so you
6
+ # have to parse them out yourself.
7
+ module StreamListener
8
+ # Called when a tag is encountered.
9
+ # @p name the tag name
10
+ # @p attrs an array of arrays of attribute/value pairs, suitable for
11
+ # use with assoc or rassoc. IE, <tag attr1="value1" attr2="value2">
12
+ # will result in
13
+ # tag_start( "tag", # [["attr1","value1"],["attr2","value2"]])
14
+ def tag_start name, attrs
15
+ end
16
+ # Called when the end tag is reached. In the case of <tag/>, tag_end
17
+ # will be called immediately after tag_start
18
+ # @p the name of the tag
19
+ def tag_end name
20
+ end
21
+ # Called when text is encountered in the document
22
+ # @p text the text content.
23
+ def text text
24
+ end
25
+ # Called when an instruction is encountered. EG: <?xsl sheet='foo'?>
26
+ # @p name the instruction name; in the example, "xsl"
27
+ # @p instruction the rest of the instruction. In the example,
28
+ # "sheet='foo'"
29
+ def instruction name, instruction
30
+ end
31
+ # Called when a comment is encountered.
32
+ # @p comment The content of the comment
33
+ def comment comment
34
+ end
35
+ # Handles a doctype declaration. Any attributes of the doctype which are
36
+ # not supplied will be nil. # EG, <!DOCTYPE me PUBLIC "foo" "bar">
37
+ # @p name the name of the doctype; EG, "me"
38
+ # @p pub_sys "PUBLIC", "SYSTEM", or nil. EG, "PUBLIC"
39
+ # @p long_name the supplied long name, or nil. EG, "foo"
40
+ # @p uri the uri of the doctype, or nil. EG, "bar"
41
+ def doctype name, pub_sys, long_name, uri
42
+ end
43
+ # Called when the doctype is done
44
+ def doctype_end
45
+ end
46
+ # If a doctype includes an ATTLIST declaration, it will cause this
47
+ # method to be called. The content is the declaration itself, unparsed.
48
+ # EG, <!ATTLIST el attr CDATA #REQUIRED> will come to this method as "el
49
+ # attr CDATA #REQUIRED". This is the same for all of the .*decl
50
+ # methods.
51
+ def attlistdecl element_name, attributes, raw_content
52
+ end
53
+ # <!ELEMENT ...>
54
+ def elementdecl content
55
+ end
56
+ # <!ENTITY ...>
57
+ # The argument passed to this method is an array of the entity
58
+ # declaration. It can be in a number of formats, but in general it
59
+ # returns (example, result):
60
+ # <!ENTITY % YN '"Yes"'>
61
+ # ["YN", "\"Yes\"", "%"]
62
+ # <!ENTITY % YN 'Yes'>
63
+ # ["YN", "Yes", "%"]
64
+ # <!ENTITY WhatHeSaid "He said %YN;">
65
+ # ["WhatHeSaid", "He said %YN;"]
66
+ # <!ENTITY open-hatch SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml">
67
+ # ["open-hatch", "SYSTEM", "http://www.textuality.com/boilerplate/OpenHatch.xml"]
68
+ # <!ENTITY open-hatch PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN" "http://www.textuality.com/boilerplate/OpenHatch.xml">
69
+ # ["open-hatch", "PUBLIC", "-//Textuality//TEXT Standard open-hatch boilerplate//EN", "http://www.textuality.com/boilerplate/OpenHatch.xml"]
70
+ # <!ENTITY hatch-pic SYSTEM "../grafix/OpenHatch.gif" NDATA gif>
71
+ # ["hatch-pic", "SYSTEM", "../grafix/OpenHatch.gif", "gif"]
72
+ def entitydecl content
73
+ end
74
+ # <!NOTATION ...>
75
+ def notationdecl content
76
+ end
77
+ # Called when %foo; is encountered in a doctype declaration.
78
+ # @p content "foo"
79
+ def entity content
80
+ end
81
+ # Called when <![CDATA[ ... ]]> is encountered in a document.
82
+ # @p content "..."
83
+ def cdata content
84
+ end
85
+ # Called when an XML PI is encountered in the document.
86
+ # EG: <?xml version="1.0" encoding="utf"?>
87
+ # @p version the version attribute value. EG, "1.0"
88
+ # @p encoding the encoding attribute value, or nil. EG, "utf"
89
+ # @p standalone the standalone attribute value, or nil. EG, nil
90
+ def xmldecl version, encoding, standalone
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: false
2
+ module REXML
3
+ class SyncEnumerator
4
+ include Enumerable
5
+
6
+ # Creates a new SyncEnumerator which enumerates rows of given
7
+ # Enumerable objects.
8
+ def initialize(*enums)
9
+ @gens = enums
10
+ @length = @gens.collect {|x| x.size }.max
11
+ end
12
+
13
+ # Returns the number of enumerated Enumerable objects, i.e. the size
14
+ # of each row.
15
+ def size
16
+ @gens.size
17
+ end
18
+
19
+ # Returns the number of enumerated Enumerable objects, i.e. the size
20
+ # of each row.
21
+ def length
22
+ @gens.length
23
+ end
24
+
25
+ # Enumerates rows of the Enumerable objects.
26
+ def each
27
+ @length.times {|i|
28
+ yield @gens.collect {|x| x[i]}
29
+ }
30
+ self
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,426 @@
1
+ # frozen_string_literal: false
2
+ require 'rexml/security'
3
+ require 'rexml/entity'
4
+ require 'rexml/doctype'
5
+ require 'rexml/child'
6
+ require 'rexml/doctype'
7
+ require 'rexml/parseexception'
8
+
9
+ module REXML
10
+ # Represents text nodes in an XML document
11
+ class Text < Child
12
+ include Comparable
13
+ # The order in which the substitutions occur
14
+ SPECIALS = [ /&(?!#?[\w-]+;)/u, /</u, />/u, /"/u, /'/u, /\r/u ]
15
+ SUBSTITUTES = ['&amp;', '&lt;', '&gt;', '&quot;', '&apos;', '&#13;']
16
+ # Characters which are substituted in written strings
17
+ SLAICEPS = [ '<', '>', '"', "'", '&' ]
18
+ SETUTITSBUS = [ /&lt;/u, /&gt;/u, /&quot;/u, /&apos;/u, /&amp;/u ]
19
+
20
+ # If +raw+ is true, then REXML leaves the value alone
21
+ attr_accessor :raw
22
+
23
+ NEEDS_A_SECOND_CHECK = /(<|&((#{Entity::NAME});|(#0*((?:\d+)|(?:x[a-fA-F0-9]+)));)?)/um
24
+ NUMERICENTITY = /&#0*((?:\d+)|(?:x[a-fA-F0-9]+));/
25
+ VALID_CHAR = [
26
+ 0x9, 0xA, 0xD,
27
+ (0x20..0xD7FF),
28
+ (0xE000..0xFFFD),
29
+ (0x10000..0x10FFFF)
30
+ ]
31
+
32
+ if String.method_defined? :encode
33
+ VALID_XML_CHARS = Regexp.new('^['+
34
+ VALID_CHAR.map { |item|
35
+ case item
36
+ when Fixnum
37
+ [item].pack('U').force_encoding('utf-8')
38
+ when Range
39
+ [item.first, '-'.ord, item.last].pack('UUU').force_encoding('utf-8')
40
+ end
41
+ }.join +
42
+ ']*$')
43
+ else
44
+ VALID_XML_CHARS = /^(
45
+ [\x09\x0A\x0D\x20-\x7E] # ASCII
46
+ | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
47
+ | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
48
+ | [\xE1-\xEC\xEE][\x80-\xBF]{2} # straight 3-byte
49
+ | \xEF[\x80-\xBE]{2} #
50
+ | \xEF\xBF[\x80-\xBD] # excluding U+fffe and U+ffff
51
+ | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
52
+ | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
53
+ | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
54
+ | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
55
+ )*$/nx;
56
+ end
57
+
58
+ # Constructor
59
+ # +arg+ if a String, the content is set to the String. If a Text,
60
+ # the object is shallowly cloned.
61
+ #
62
+ # +respect_whitespace+ (boolean, false) if true, whitespace is
63
+ # respected
64
+ #
65
+ # +parent+ (nil) if this is a Parent object, the parent
66
+ # will be set to this.
67
+ #
68
+ # +raw+ (nil) This argument can be given three values.
69
+ # If true, then the value of used to construct this object is expected to
70
+ # contain no unescaped XML markup, and REXML will not change the text. If
71
+ # this value is false, the string may contain any characters, and REXML will
72
+ # escape any and all defined entities whose values are contained in the
73
+ # text. If this value is nil (the default), then the raw value of the
74
+ # parent will be used as the raw value for this node. If there is no raw
75
+ # value for the parent, and no value is supplied, the default is false.
76
+ # Use this field if you have entities defined for some text, and you don't
77
+ # want REXML to escape that text in output.
78
+ # Text.new( "<&", false, nil, false ) #-> "&lt;&amp;"
79
+ # Text.new( "&lt;&amp;", false, nil, false ) #-> "&amp;lt;&amp;amp;"
80
+ # Text.new( "<&", false, nil, true ) #-> Parse exception
81
+ # Text.new( "&lt;&amp;", false, nil, true ) #-> "&lt;&amp;"
82
+ # # Assume that the entity "s" is defined to be "sean"
83
+ # # and that the entity "r" is defined to be "russell"
84
+ # Text.new( "sean russell" ) #-> "&s; &r;"
85
+ # Text.new( "sean russell", false, nil, true ) #-> "sean russell"
86
+ #
87
+ # +entity_filter+ (nil) This can be an array of entities to match in the
88
+ # supplied text. This argument is only useful if +raw+ is set to false.
89
+ # Text.new( "sean russell", false, nil, false, ["s"] ) #-> "&s; russell"
90
+ # Text.new( "sean russell", false, nil, true, ["s"] ) #-> "sean russell"
91
+ # In the last example, the +entity_filter+ argument is ignored.
92
+ #
93
+ # +illegal+ INTERNAL USE ONLY
94
+ def initialize(arg, respect_whitespace=false, parent=nil, raw=nil,
95
+ entity_filter=nil, illegal=NEEDS_A_SECOND_CHECK )
96
+
97
+ @raw = false
98
+ @parent = nil
99
+
100
+ if parent
101
+ super( parent )
102
+ @raw = parent.raw
103
+ end
104
+
105
+ @raw = raw unless raw.nil?
106
+ @entity_filter = entity_filter
107
+ clear_cache
108
+
109
+ if arg.kind_of? String
110
+ @string = arg.dup
111
+ @string.squeeze!(" \n\t") unless respect_whitespace
112
+ elsif arg.kind_of? Text
113
+ @string = arg.to_s
114
+ @raw = arg.raw
115
+ elsif
116
+ raise "Illegal argument of type #{arg.type} for Text constructor (#{arg})"
117
+ end
118
+
119
+ @string.gsub!( /\r\n?/, "\n" )
120
+
121
+ Text.check(@string, illegal, doctype) if @raw
122
+ end
123
+
124
+ def parent= parent
125
+ super(parent)
126
+ Text.check(@string, NEEDS_A_SECOND_CHECK, doctype) if @raw and @parent
127
+ end
128
+
129
+ # check for illegal characters
130
+ def Text.check string, pattern, doctype
131
+
132
+ # illegal anywhere
133
+ if string !~ VALID_XML_CHARS
134
+ if String.method_defined? :encode
135
+ string.chars.each do |c|
136
+ case c.ord
137
+ when *VALID_CHAR
138
+ else
139
+ raise "Illegal character #{c.inspect} in raw string \"#{string}\""
140
+ end
141
+ end
142
+ else
143
+ string.scan(/[\x00-\x7F]|[\x80-\xBF][\xC0-\xF0]*|[\xC0-\xF0]/n) do |c|
144
+ case c.unpack('U')
145
+ when *VALID_CHAR
146
+ else
147
+ raise "Illegal character #{c.inspect} in raw string \"#{string}\""
148
+ end
149
+ end
150
+ end
151
+ end
152
+
153
+ # context sensitive
154
+ string.scan(pattern) do
155
+ if $1[-1] != ?;
156
+ raise "Illegal character '#{$1}' in raw string \"#{string}\""
157
+ elsif $1[0] == ?&
158
+ if $5 and $5[0] == ?#
159
+ case ($5[1] == ?x ? $5[2..-1].to_i(16) : $5[1..-1].to_i)
160
+ when *VALID_CHAR
161
+ else
162
+ raise "Illegal character '#{$1}' in raw string \"#{string}\""
163
+ end
164
+ # FIXME: below can't work but this needs API change.
165
+ # elsif @parent and $3 and !SUBSTITUTES.include?($1)
166
+ # if !doctype or !doctype.entities.has_key?($3)
167
+ # raise "Undeclared entity '#{$1}' in raw string \"#{string}\""
168
+ # end
169
+ end
170
+ end
171
+ end
172
+ end
173
+
174
+ def node_type
175
+ :text
176
+ end
177
+
178
+ def empty?
179
+ @string.size==0
180
+ end
181
+
182
+
183
+ def clone
184
+ return Text.new(self)
185
+ end
186
+
187
+
188
+ # Appends text to this text node. The text is appended in the +raw+ mode
189
+ # of this text node.
190
+ #
191
+ # +returns+ the text itself to enable method chain like
192
+ # 'text << "XXX" << "YYY"'.
193
+ def <<( to_append )
194
+ @string << to_append.gsub( /\r\n?/, "\n" )
195
+ clear_cache
196
+ self
197
+ end
198
+
199
+
200
+ # +other+ a String or a Text
201
+ # +returns+ the result of (to_s <=> arg.to_s)
202
+ def <=>( other )
203
+ to_s() <=> other.to_s
204
+ end
205
+
206
+ def doctype
207
+ if @parent
208
+ doc = @parent.document
209
+ doc.doctype if doc
210
+ end
211
+ end
212
+
213
+ REFERENCE = /#{Entity::REFERENCE}/
214
+ # Returns the string value of this text node. This string is always
215
+ # escaped, meaning that it is a valid XML text node string, and all
216
+ # entities that can be escaped, have been inserted. This method respects
217
+ # the entity filter set in the constructor.
218
+ #
219
+ # # Assume that the entity "s" is defined to be "sean", and that the
220
+ # # entity "r" is defined to be "russell"
221
+ # t = Text.new( "< & sean russell", false, nil, false, ['s'] )
222
+ # t.to_s #-> "&lt; &amp; &s; russell"
223
+ # t = Text.new( "< & &s; russell", false, nil, false )
224
+ # t.to_s #-> "&lt; &amp; &s; russell"
225
+ # u = Text.new( "sean russell", false, nil, true )
226
+ # u.to_s #-> "sean russell"
227
+ def to_s
228
+ return @string if @raw
229
+ return @normalized if @normalized
230
+
231
+ @normalized = Text::normalize( @string, doctype, @entity_filter )
232
+ end
233
+
234
+ def inspect
235
+ @string.inspect
236
+ end
237
+
238
+ # Returns the string value of this text. This is the text without
239
+ # entities, as it might be used programmatically, or printed to the
240
+ # console. This ignores the 'raw' attribute setting, and any
241
+ # entity_filter.
242
+ #
243
+ # # Assume that the entity "s" is defined to be "sean", and that the
244
+ # # entity "r" is defined to be "russell"
245
+ # t = Text.new( "< & sean russell", false, nil, false, ['s'] )
246
+ # t.value #-> "< & sean russell"
247
+ # t = Text.new( "< & &s; russell", false, nil, false )
248
+ # t.value #-> "< & sean russell"
249
+ # u = Text.new( "sean russell", false, nil, true )
250
+ # u.value #-> "sean russell"
251
+ def value
252
+ return @unnormalized if @unnormalized
253
+ @unnormalized = Text::unnormalize( @string, doctype )
254
+ end
255
+
256
+ # Sets the contents of this text node. This expects the text to be
257
+ # unnormalized. It returns self.
258
+ #
259
+ # e = Element.new( "a" )
260
+ # e.add_text( "foo" ) # <a>foo</a>
261
+ # e[0].value = "bar" # <a>bar</a>
262
+ # e[0].value = "<a>" # <a>&lt;a&gt;</a>
263
+ def value=( val )
264
+ @string = val.gsub( /\r\n?/, "\n" )
265
+ clear_cache
266
+ @raw = false
267
+ end
268
+
269
+ def wrap(string, width, addnewline=false)
270
+ # Recursively wrap string at width.
271
+ return string if string.length <= width
272
+ place = string.rindex(' ', width) # Position in string with last ' ' before cutoff
273
+ if addnewline then
274
+ return "\n" + string[0,place] + "\n" + wrap(string[place+1..-1], width)
275
+ else
276
+ return string[0,place] + "\n" + wrap(string[place+1..-1], width)
277
+ end
278
+ end
279
+
280
+ def indent_text(string, level=1, style="\t", indentfirstline=true)
281
+ return string if level < 0
282
+ new_string = ''
283
+ string.each_line { |line|
284
+ indent_string = style * level
285
+ new_line = (indent_string + line).sub(/[\s]+$/,'')
286
+ new_string << new_line
287
+ }
288
+ new_string.strip! unless indentfirstline
289
+ return new_string
290
+ end
291
+
292
+ # == DEPRECATED
293
+ # See REXML::Formatters
294
+ #
295
+ def write( writer, indent=-1, transitive=false, ie_hack=false )
296
+ Kernel.warn("#{self.class.name}.write is deprecated. See REXML::Formatters")
297
+ formatter = if indent > -1
298
+ REXML::Formatters::Pretty.new( indent )
299
+ else
300
+ REXML::Formatters::Default.new
301
+ end
302
+ formatter.write( self, writer )
303
+ end
304
+
305
+ # FIXME
306
+ # This probably won't work properly
307
+ def xpath
308
+ path = @parent.xpath
309
+ path += "/text()"
310
+ return path
311
+ end
312
+
313
+ # Writes out text, substituting special characters beforehand.
314
+ # +out+ A String, IO, or any other object supporting <<( String )
315
+ # +input+ the text to substitute and the write out
316
+ #
317
+ # z=utf8.unpack("U*")
318
+ # ascOut=""
319
+ # z.each{|r|
320
+ # if r < 0x100
321
+ # ascOut.concat(r.chr)
322
+ # else
323
+ # ascOut.concat(sprintf("&#x%x;", r))
324
+ # end
325
+ # }
326
+ # puts ascOut
327
+ def write_with_substitution out, input
328
+ copy = input.clone
329
+ # Doing it like this rather than in a loop improves the speed
330
+ copy.gsub!( SPECIALS[0], SUBSTITUTES[0] )
331
+ copy.gsub!( SPECIALS[1], SUBSTITUTES[1] )
332
+ copy.gsub!( SPECIALS[2], SUBSTITUTES[2] )
333
+ copy.gsub!( SPECIALS[3], SUBSTITUTES[3] )
334
+ copy.gsub!( SPECIALS[4], SUBSTITUTES[4] )
335
+ copy.gsub!( SPECIALS[5], SUBSTITUTES[5] )
336
+ out << copy
337
+ end
338
+
339
+ private
340
+ def clear_cache
341
+ @normalized = nil
342
+ @unnormalized = nil
343
+ end
344
+
345
+ # Reads text, substituting entities
346
+ def Text::read_with_substitution( input, illegal=nil )
347
+ copy = input.clone
348
+
349
+ if copy =~ illegal
350
+ raise ParseException.new( "malformed text: Illegal character #$& in \"#{copy}\"" )
351
+ end if illegal
352
+
353
+ copy.gsub!( /\r\n?/, "\n" )
354
+ if copy.include? ?&
355
+ copy.gsub!( SETUTITSBUS[0], SLAICEPS[0] )
356
+ copy.gsub!( SETUTITSBUS[1], SLAICEPS[1] )
357
+ copy.gsub!( SETUTITSBUS[2], SLAICEPS[2] )
358
+ copy.gsub!( SETUTITSBUS[3], SLAICEPS[3] )
359
+ copy.gsub!( SETUTITSBUS[4], SLAICEPS[4] )
360
+ copy.gsub!( /&#0*((?:\d+)|(?:x[a-f0-9]+));/ ) {
361
+ m=$1
362
+ #m='0' if m==''
363
+ m = "0#{m}" if m[0] == ?x
364
+ [Integer(m)].pack('U*')
365
+ }
366
+ end
367
+ copy
368
+ end
369
+
370
+ EREFERENCE = /&(?!#{Entity::NAME};)/
371
+ # Escapes all possible entities
372
+ def Text::normalize( input, doctype=nil, entity_filter=nil )
373
+ copy = input.to_s
374
+ # Doing it like this rather than in a loop improves the speed
375
+ #copy = copy.gsub( EREFERENCE, '&amp;' )
376
+ copy = copy.gsub( "&", "&amp;" )
377
+ if doctype
378
+ # Replace all ampersands that aren't part of an entity
379
+ doctype.entities.each_value do |entity|
380
+ copy = copy.gsub( entity.value,
381
+ "&#{entity.name};" ) if entity.value and
382
+ not( entity_filter and entity_filter.include?(entity.name) )
383
+ end
384
+ else
385
+ # Replace all ampersands that aren't part of an entity
386
+ DocType::DEFAULT_ENTITIES.each_value do |entity|
387
+ copy = copy.gsub(entity.value, "&#{entity.name};" )
388
+ end
389
+ end
390
+ copy
391
+ end
392
+
393
+ # Unescapes all possible entities
394
+ def Text::unnormalize( string, doctype=nil, filter=nil, illegal=nil )
395
+ sum = 0
396
+ string.gsub( /\r\n?/, "\n" ).gsub( REFERENCE ) {
397
+ s = Text.expand($&, doctype, filter)
398
+ if sum + s.bytesize > Security.entity_expansion_text_limit
399
+ raise "entity expansion has grown too large"
400
+ else
401
+ sum += s.bytesize
402
+ end
403
+ s
404
+ }
405
+ end
406
+
407
+ def Text.expand(ref, doctype, filter)
408
+ if ref[1] == ?#
409
+ if ref[2] == ?x
410
+ [ref[3...-1].to_i(16)].pack('U*')
411
+ else
412
+ [ref[2...-1].to_i].pack('U*')
413
+ end
414
+ elsif ref == '&amp;'
415
+ '&'
416
+ elsif filter and filter.include?( ref[1...-1] )
417
+ ref
418
+ elsif doctype
419
+ doctype.entity( ref[1...-1] ) or ref
420
+ else
421
+ entity_value = DocType::DEFAULT_ENTITIES[ ref[1...-1] ]
422
+ entity_value ? entity_value.value : ref
423
+ end
424
+ end
425
+ end
426
+ end