asip-meteor 0.9.0.4 → 0.9.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/meteor.rb +311 -173
- metadata +2 -2
data/lib/meteor.rb
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
19
|
#
|
20
20
|
# @author Yasumasa Ashida
|
21
|
-
# @version 0.9.0.
|
21
|
+
# @version 0.9.0.5
|
22
22
|
#
|
23
23
|
if RUBY_VERSION < '1.9.0' then
|
24
24
|
require 'kconv'
|
@@ -27,7 +27,7 @@ end
|
|
27
27
|
|
28
28
|
module Meteor
|
29
29
|
|
30
|
-
VERSION = "0.9.0.
|
30
|
+
VERSION = "0.9.0.5"
|
31
31
|
|
32
32
|
#
|
33
33
|
# 要素クラス
|
@@ -720,6 +720,8 @@ module Meteor
|
|
720
720
|
#PLUS_1 = "\\\+"
|
721
721
|
#PLUS_2 = "\\\\\\+"
|
722
722
|
|
723
|
+
ESCAPE_ENTITY_REF = ''
|
724
|
+
|
723
725
|
SUB_REGEX1 = "(\\\\*)\\\\([0-9]+)"
|
724
726
|
SUB_REGEX2 = "\\1\\1\\\\\\\\\\2"
|
725
727
|
SUB_REGEX3 = "\\1\\1\\1\\1\\\\\\\\\\\\\\\\\\2"
|
@@ -795,6 +797,9 @@ module Meteor
|
|
795
797
|
#@pattern_cc_2 = nil
|
796
798
|
#@pattern_cc_2_1 = nil
|
797
799
|
#@pattern_cc_2_2 = nil
|
800
|
+
#@pattern_2 = nil
|
801
|
+
#@pattern_1 = nil
|
802
|
+
#@pattern_1b = nil
|
798
803
|
#@cnt = 0
|
799
804
|
#@position = 0
|
800
805
|
#@position2 = 0
|
@@ -1219,6 +1224,9 @@ module Meteor
|
|
1219
1224
|
|
1220
1225
|
@sbuf = '';
|
1221
1226
|
|
1227
|
+
@pattern_2 = Meteor::Core::Util::PatternCache.get(@pattern_cc_2)
|
1228
|
+
@pattern_1b = Meteor::Core::Util::PatternCache.get(@pattern_cc_1b);
|
1229
|
+
|
1222
1230
|
if RUBY_VERSION >= '1.9.0' then
|
1223
1231
|
|
1224
1232
|
@position = 0
|
@@ -1231,8 +1239,7 @@ module Meteor
|
|
1231
1239
|
|
1232
1240
|
@position2 = @res.end(0)
|
1233
1241
|
|
1234
|
-
@
|
1235
|
-
@res = @pattern.match(@root.document,@position)
|
1242
|
+
@res = @pattern_2.match(@root.document,@position)
|
1236
1243
|
|
1237
1244
|
if @res then
|
1238
1245
|
|
@@ -1289,8 +1296,7 @@ module Meteor
|
|
1289
1296
|
end
|
1290
1297
|
else
|
1291
1298
|
|
1292
|
-
@
|
1293
|
-
@res = @pattern.match(@root.document,@position)
|
1299
|
+
@res = @pattern_2.match(@root.document,@position)
|
1294
1300
|
|
1295
1301
|
if @res then
|
1296
1302
|
@cnt -= 1
|
@@ -1313,7 +1319,7 @@ module Meteor
|
|
1313
1319
|
end
|
1314
1320
|
end
|
1315
1321
|
|
1316
|
-
@pattern =
|
1322
|
+
@pattern = @pattern_1b
|
1317
1323
|
end
|
1318
1324
|
else
|
1319
1325
|
|
@@ -1326,9 +1332,8 @@ module Meteor
|
|
1326
1332
|
if @cnt > 0 then
|
1327
1333
|
|
1328
1334
|
@rx_document2 = @res.post_match
|
1329
|
-
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc_2)
|
1330
1335
|
|
1331
|
-
@res = @
|
1336
|
+
@res = @pattern_2.match(@rx_document)
|
1332
1337
|
|
1333
1338
|
if @res then
|
1334
1339
|
|
@@ -1385,8 +1390,7 @@ module Meteor
|
|
1385
1390
|
end
|
1386
1391
|
else
|
1387
1392
|
|
1388
|
-
@
|
1389
|
-
@res = @pattern.match(@rx_document)
|
1393
|
+
@res = @pattern_2.match(@rx_document)
|
1390
1394
|
|
1391
1395
|
if @res then
|
1392
1396
|
@cnt -= 1
|
@@ -1409,7 +1413,7 @@ module Meteor
|
|
1409
1413
|
end
|
1410
1414
|
end
|
1411
1415
|
|
1412
|
-
@pattern =
|
1416
|
+
@pattern = @pattern_1b
|
1413
1417
|
end
|
1414
1418
|
end
|
1415
1419
|
|
@@ -1627,6 +1631,9 @@ module Meteor
|
|
1627
1631
|
|
1628
1632
|
@sbuf = ''
|
1629
1633
|
|
1634
|
+
@pattern_2 = Meteor::Core::Util::PatternCache.get(@pattern_cc_2)
|
1635
|
+
@pattern_1b = Meteor::Core::Util::PatternCache.get(@pattern_cc_1b);
|
1636
|
+
|
1630
1637
|
if RUBY_VERSION >= '1.9.0' then
|
1631
1638
|
|
1632
1639
|
@position = 0
|
@@ -1639,8 +1646,7 @@ module Meteor
|
|
1639
1646
|
|
1640
1647
|
@position2 = @res.end(0)
|
1641
1648
|
|
1642
|
-
@
|
1643
|
-
@res = @pattern.match(@root.document,@position)
|
1649
|
+
@res = @pattern_2.match(@root.document,@position)
|
1644
1650
|
|
1645
1651
|
if @res then
|
1646
1652
|
|
@@ -1696,8 +1702,7 @@ module Meteor
|
|
1696
1702
|
end
|
1697
1703
|
else
|
1698
1704
|
|
1699
|
-
@
|
1700
|
-
@res = @pattern.match(@root.document,@position)
|
1705
|
+
@res = @pattern_2.match(@root.document,@position)
|
1701
1706
|
|
1702
1707
|
if @res then
|
1703
1708
|
|
@@ -1721,7 +1726,7 @@ module Meteor
|
|
1721
1726
|
end
|
1722
1727
|
end
|
1723
1728
|
|
1724
|
-
@pattern =
|
1729
|
+
@pattern = @pattern_1b
|
1725
1730
|
end
|
1726
1731
|
else
|
1727
1732
|
|
@@ -1735,8 +1740,7 @@ module Meteor
|
|
1735
1740
|
|
1736
1741
|
@rx_document2 = @res.post_match
|
1737
1742
|
|
1738
|
-
@
|
1739
|
-
@res = @pattern.match(@rx_document)
|
1743
|
+
@res = @pattern_2.match(@rx_document)
|
1740
1744
|
|
1741
1745
|
if @res then
|
1742
1746
|
|
@@ -1792,8 +1796,7 @@ module Meteor
|
|
1792
1796
|
end
|
1793
1797
|
else
|
1794
1798
|
|
1795
|
-
@
|
1796
|
-
@res = @pattern.match(@rx_document)
|
1799
|
+
@res = @pattern_2.match(@rx_document)
|
1797
1800
|
|
1798
1801
|
if @res then
|
1799
1802
|
|
@@ -1817,7 +1820,7 @@ module Meteor
|
|
1817
1820
|
end
|
1818
1821
|
end
|
1819
1822
|
|
1820
|
-
@pattern =
|
1823
|
+
@pattern = @pattern_1b
|
1821
1824
|
end
|
1822
1825
|
end
|
1823
1826
|
|
@@ -2994,23 +2997,54 @@ module Meteor
|
|
2994
2997
|
|
2995
2998
|
#@@pattern_true = Regexp.new(TRUE)
|
2996
2999
|
#@@pattern_false = Regexp.new(FALSE)
|
2997
|
-
|
3000
|
+
|
2998
3001
|
TYPE_L = 'type'
|
2999
3002
|
TYPE_U = 'TYPE'
|
3000
|
-
|
3001
|
-
|
3002
|
-
|
3003
|
-
|
3004
|
-
|
3005
|
-
|
3006
|
-
|
3007
|
-
|
3008
|
-
|
3009
|
-
|
3010
|
-
|
3011
|
-
|
3012
|
-
|
3013
|
-
|
3003
|
+
|
3004
|
+
if RUBY_VERSION >= '1.9.0' then
|
3005
|
+
TABLE_FOR_ESCAPE_ = {
|
3006
|
+
'&' => '&',
|
3007
|
+
'"' => '"',
|
3008
|
+
'\'' => ''',
|
3009
|
+
'<' => '<',
|
3010
|
+
'>' => '>',
|
3011
|
+
' ' => ' ',
|
3012
|
+
}
|
3013
|
+
|
3014
|
+
TABLE_FOR_ESCAPE_CONTENT_ = {
|
3015
|
+
'&' => '&',
|
3016
|
+
'"' => '"',
|
3017
|
+
'\'' => ''',
|
3018
|
+
'<' => '<',
|
3019
|
+
'>' => '>',
|
3020
|
+
' ' => ' ',
|
3021
|
+
"\n" => '<br>',
|
3022
|
+
}
|
3023
|
+
|
3024
|
+
PATTERN_ESCAPE = "[&\"'<> ]"
|
3025
|
+
PATTERN_ESCAPE_CONTENT = "[&\"'<> \\n]"
|
3026
|
+
|
3027
|
+
@@pattern_escape = Regexp.new(PATTERN_ESCAPE)
|
3028
|
+
@@pattern_escape_content = Regexp.new(PATTERN_ESCAPE_CONTENT)
|
3029
|
+
else
|
3030
|
+
@@pattern_and_1 = Regexp.new(AND_1)
|
3031
|
+
@@pattern_lt_1 = Regexp.new(LT_1)
|
3032
|
+
@@pattern_gt_1 = Regexp.new(GT_1)
|
3033
|
+
@@pattern_dq_1 = Regexp.new(DOUBLE_QUATATION)
|
3034
|
+
@@pattern_space_1 = Regexp.new(SPACE)
|
3035
|
+
@@pattern_br_1 = Regexp.new(BR_1)
|
3036
|
+
@@pattern_lt_2 = Regexp.new(LT_2)
|
3037
|
+
@@pattern_gt_2 = Regexp.new(GT_2)
|
3038
|
+
@@pattern_dq_2 = Regexp.new(QO_2)
|
3039
|
+
@@pattern_space_2 = Regexp.new(NBSP_2)
|
3040
|
+
@@pattern_and_2 = Regexp.new(AND_2)
|
3041
|
+
@@pattern_br_2 = Regexp.new(BR_2)
|
3042
|
+
end
|
3043
|
+
|
3044
|
+
|
3045
|
+
PATTERN_UNESCAPE = '&(amp|quot|apos|gt|lt|nbsp);'
|
3046
|
+
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
3047
|
+
|
3014
3048
|
#@@pattern_match_tag = Regexp.new(MATCH_TAG)
|
3015
3049
|
@@pattern_set_mono1 = Regexp.new(SET_MONO_1)
|
3016
3050
|
#@@pattern_match_tag2 = Regexp.new(MATCH_TAG_2)
|
@@ -3532,39 +3566,46 @@ module Meteor
|
|
3532
3566
|
|
3533
3567
|
def escape(element)
|
3534
3568
|
#特殊文字の置換
|
3535
|
-
|
3536
|
-
|
3537
|
-
element.
|
3538
|
-
|
3539
|
-
|
3540
|
-
|
3541
|
-
element.
|
3542
|
-
|
3543
|
-
|
3544
|
-
|
3545
|
-
element.
|
3546
|
-
|
3547
|
-
|
3548
|
-
|
3549
|
-
element.
|
3550
|
-
|
3551
|
-
|
3552
|
-
|
3553
|
-
element.
|
3569
|
+
if RUBY_VERSION < '1.9.0' then
|
3570
|
+
#「&」->「&」
|
3571
|
+
if element.include?(AND_1) then
|
3572
|
+
element.gsub!(@@pattern_and_1,AND_2)
|
3573
|
+
end
|
3574
|
+
#「<」->「<」
|
3575
|
+
if element.include?(LT_1) then
|
3576
|
+
element.gsub!(@@pattern_lt_1,LT_2)
|
3577
|
+
end
|
3578
|
+
#「>」->「>」
|
3579
|
+
if element.include?(GT_1) then
|
3580
|
+
element.gsub!(@@pattern_gt_1,GT_2)
|
3581
|
+
end
|
3582
|
+
#「"」->「"l」
|
3583
|
+
if element.include?(DOUBLE_QUATATION) then
|
3584
|
+
element.gsub!(@@pattern_dq_1,QO_2)
|
3585
|
+
end
|
3586
|
+
#「 」->「 」
|
3587
|
+
if element.include?(SPACE) then
|
3588
|
+
element.gsub!(@@pattern_space_1,NBSP_2)
|
3589
|
+
end
|
3590
|
+
else
|
3591
|
+
element.gsub!(@@pattern_escape, TABLE_FOR_ESCAPE_)
|
3554
3592
|
end
|
3555
|
-
|
3556
3593
|
element
|
3557
3594
|
end
|
3558
3595
|
private :escape
|
3559
3596
|
|
3560
3597
|
def escapeContent(element,elmName)
|
3561
|
-
|
3562
|
-
|
3563
|
-
|
3564
|
-
|
3565
|
-
|
3598
|
+
if RUBY_VERSION < '1.9.0' then
|
3599
|
+
element = escape(element)
|
3600
|
+
|
3601
|
+
if !isMatch(MATCH_TAG_2,elmName) then
|
3602
|
+
#「¥r?¥n」->「<br>」
|
3603
|
+
element.gsub!(@@pattern_br_1, BR_2)
|
3604
|
+
end
|
3605
|
+
else
|
3606
|
+
element.gsub!(@@pattern_escape_content, TABLE_FOR_ESCAPE_CONTENT_)
|
3566
3607
|
end
|
3567
|
-
|
3608
|
+
|
3568
3609
|
element
|
3569
3610
|
end
|
3570
3611
|
private :escapeContent
|
@@ -3572,25 +3613,36 @@ module Meteor
|
|
3572
3613
|
def unescape(element)
|
3573
3614
|
#特殊文字の置換
|
3574
3615
|
#「<」<-「<」
|
3575
|
-
if element.include?(LT_2) then
|
3576
|
-
|
3577
|
-
end
|
3616
|
+
#if element.include?(LT_2) then
|
3617
|
+
# element.gsub!(@@pattern_lt_2,LT_1)
|
3618
|
+
#end
|
3578
3619
|
#「>」<-「>」
|
3579
|
-
if element.include?(GT_2) then
|
3580
|
-
|
3581
|
-
end
|
3620
|
+
#if element.include?(GT_2) then
|
3621
|
+
# element.gsub!(@@pattern_gt_2,GT_1)
|
3622
|
+
#end
|
3582
3623
|
#「"」<-「"l」
|
3583
|
-
if element.include?(QO_2) then
|
3584
|
-
|
3585
|
-
end
|
3624
|
+
#if element.include?(QO_2) then
|
3625
|
+
# element.gsub!(@@pattern_dq_2,DOUBLE_QUATATION)
|
3626
|
+
#end
|
3586
3627
|
#「 」<-「 」
|
3587
|
-
if element.include?(NBSP_2) then
|
3588
|
-
|
3589
|
-
end
|
3628
|
+
#if element.include?(NBSP_2) then
|
3629
|
+
# element.gsub!(@@pattern_space_2,SPACE)
|
3630
|
+
#end
|
3590
3631
|
#「&」<-「&」
|
3591
|
-
if element.include?(AND_2) then
|
3592
|
-
|
3593
|
-
end
|
3632
|
+
#if element.include?(AND_2) then
|
3633
|
+
# element.gsub!(@@pattern_and_2,AND_1)
|
3634
|
+
#end
|
3635
|
+
element.gsub!(@@pattern_unescape){
|
3636
|
+
case $1
|
3637
|
+
when 'amp' then '&'
|
3638
|
+
when 'quot' then '"'
|
3639
|
+
when 'apos' then '\''
|
3640
|
+
when 'gt' then '>'
|
3641
|
+
when 'lt' then '<'
|
3642
|
+
when 'nbsp' then ' '
|
3643
|
+
end
|
3644
|
+
}
|
3645
|
+
|
3594
3646
|
element
|
3595
3647
|
end
|
3596
3648
|
private :unescape
|
@@ -3707,19 +3759,53 @@ module Meteor
|
|
3707
3759
|
TYPE_L = 'type'
|
3708
3760
|
TYPE_U = 'TYPE'
|
3709
3761
|
|
3710
|
-
|
3711
|
-
|
3712
|
-
|
3713
|
-
|
3714
|
-
|
3715
|
-
|
3716
|
-
|
3717
|
-
|
3718
|
-
|
3719
|
-
|
3720
|
-
|
3721
|
-
|
3722
|
-
|
3762
|
+
if RUBY_VERSION >= '1.9.0' then
|
3763
|
+
TABLE_FOR_ESCAPE_ = {
|
3764
|
+
'&' => '&',
|
3765
|
+
'"' => '"',
|
3766
|
+
'\'' => ''',
|
3767
|
+
'<' => '<',
|
3768
|
+
'>' => '>',
|
3769
|
+
' ' => ' ',
|
3770
|
+
}
|
3771
|
+
|
3772
|
+
TABLE_FOR_ESCAPE_CONTENT_ = {
|
3773
|
+
'&' => '&',
|
3774
|
+
'"' => '"',
|
3775
|
+
'\'' => ''',
|
3776
|
+
'<' => '<',
|
3777
|
+
'>' => '>',
|
3778
|
+
' ' => ' ',
|
3779
|
+
"\n" => '<br/>',
|
3780
|
+
}
|
3781
|
+
|
3782
|
+
PATTERN_ESCAPE = "[&\"'<> ]"
|
3783
|
+
PATTERN_ESCAPE_CONTENT = "[&\"'<> \\n]"
|
3784
|
+
@@pattern_escape = Regexp.new(PATTERN_ESCAPE)
|
3785
|
+
@@pattern_escape_content = Regexp.new(PATTERN_ESCAPE_CONTENT)
|
3786
|
+
|
3787
|
+
else
|
3788
|
+
|
3789
|
+
@@pattern_and_1 = Regexp.new(AND_1)
|
3790
|
+
@@pattern_lt_1 = Regexp.new(LT_1)
|
3791
|
+
@@pattern_gt_1 = Regexp.new(GT_1)
|
3792
|
+
@@pattern_dq_1 = Regexp.new(DOUBLE_QUATATION)
|
3793
|
+
@@pattern_ap_1 = Regexp.new(AP_1)
|
3794
|
+
@@pattern_space_1 = Regexp.new(SPACE)
|
3795
|
+
@@pattern_br_1 = Regexp.new(BR_1)
|
3796
|
+
@@pattern_lt_2 = Regexp.new(LT_2)
|
3797
|
+
@@pattern_gt_2 = Regexp.new(GT_2)
|
3798
|
+
@@pattern_dq_2 = Regexp.new(QO_2)
|
3799
|
+
@@pattern_ap_2 = Regexp.new(AP_2)
|
3800
|
+
@@pattern_space_2 = Regexp.new(NBSP_2)
|
3801
|
+
@@pattern_and_2 = Regexp.new(AND_2)
|
3802
|
+
@@pattern_br_2 = Regexp.new(BR_3)
|
3803
|
+
|
3804
|
+
end
|
3805
|
+
|
3806
|
+
PATTERN_UNESCAPE = '&(amp|quot|apos|gt|lt|nbsp);'
|
3807
|
+
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
3808
|
+
|
3723
3809
|
#@@pattern_match_tag = Regexp.new(MATCH_TAG)
|
3724
3810
|
@@pattern_set_mono1 = Regexp.new(SET_MONO_1)
|
3725
3811
|
#@@pattern_match_tag2 = Regexp.new(MATCH_TAG_2)
|
@@ -3990,39 +4076,51 @@ module Meteor
|
|
3990
4076
|
|
3991
4077
|
def escape(element)
|
3992
4078
|
#特殊文字の置換
|
3993
|
-
|
3994
|
-
|
3995
|
-
element.
|
3996
|
-
|
3997
|
-
|
3998
|
-
|
3999
|
-
element.
|
4000
|
-
|
4001
|
-
|
4002
|
-
|
4003
|
-
element.
|
4004
|
-
|
4005
|
-
|
4006
|
-
|
4007
|
-
element.
|
4008
|
-
|
4009
|
-
|
4010
|
-
|
4011
|
-
element.
|
4079
|
+
if RUBY_VERSION < '1.9.0' then
|
4080
|
+
#「&」->「&」
|
4081
|
+
if element.include?(AND_1) then
|
4082
|
+
element.gsub!(@@pattern_and_1,AND_2)
|
4083
|
+
end
|
4084
|
+
#「<」->「<」
|
4085
|
+
if element.include?(LT_1) then
|
4086
|
+
element.gsub!(@@pattern_lt_1,LT_2)
|
4087
|
+
end
|
4088
|
+
#「>」->「>」
|
4089
|
+
if element.include?(GT_1) then
|
4090
|
+
element.gsub!(@@pattern_gt_1,GT_2)
|
4091
|
+
end
|
4092
|
+
#「"」->「"l」
|
4093
|
+
if element.include?(DOUBLE_QUATATION) then
|
4094
|
+
element.gsub!(@@pattern_dq_1,QO_2)
|
4095
|
+
end
|
4096
|
+
#「'」->「'」
|
4097
|
+
if element.include?(AP_1) then
|
4098
|
+
element.gsub!(@@pattern_ap_1,AP_2)
|
4099
|
+
end
|
4100
|
+
#「 」->「 」
|
4101
|
+
if element.include?(SPACE) then
|
4102
|
+
element.gsub!(@@pattern_space_1,NBSP_2)
|
4103
|
+
end
|
4104
|
+
else
|
4105
|
+
element.gsub!(@@pattern_escape,TABLE_FOR_ESCAPE_)
|
4012
4106
|
end
|
4013
|
-
|
4107
|
+
|
4014
4108
|
element
|
4015
4109
|
end
|
4016
4110
|
private :escape
|
4017
4111
|
|
4018
4112
|
def escapeContent(element,elmName)
|
4019
|
-
|
4020
|
-
|
4021
|
-
|
4022
|
-
|
4023
|
-
|
4113
|
+
|
4114
|
+
if RUBY_VERSION < '1.9.0' then
|
4115
|
+
element = escape(element)
|
4116
|
+
|
4117
|
+
if !isMatch(MATCH_TAG_2,elmName) then
|
4118
|
+
#「¥r?¥n」->「<br>」
|
4119
|
+
element.gsub!(@@pattern_br_1, BR_2)
|
4120
|
+
end
|
4121
|
+
else
|
4122
|
+
element.gsub!(@@pattern_escape_content, TABLE_FOR_ESCAPE_CONTENT_)
|
4024
4123
|
end
|
4025
|
-
|
4026
4124
|
element
|
4027
4125
|
end
|
4028
4126
|
private :escapeContent
|
@@ -4030,26 +4128,36 @@ module Meteor
|
|
4030
4128
|
def unescape(element)
|
4031
4129
|
#特殊文字の置換
|
4032
4130
|
#「<」<-「<」
|
4033
|
-
if element.include?(LT_2) then
|
4034
|
-
|
4035
|
-
end
|
4131
|
+
#if element.include?(LT_2) then
|
4132
|
+
# element.gsub!(@@pattern_lt_2,LT_1)
|
4133
|
+
#end
|
4036
4134
|
#「>」<-「>」
|
4037
|
-
if element.include?(GT_2) then
|
4038
|
-
|
4039
|
-
end
|
4135
|
+
#if element.include?(GT_2) then
|
4136
|
+
# element.gsub!(@@pattern_gt_2,GT_1)
|
4137
|
+
#end
|
4040
4138
|
#「"」<-「"l」
|
4041
|
-
if element.include?(QO_2) then
|
4042
|
-
|
4043
|
-
end
|
4139
|
+
#if element.include?(QO_2) then
|
4140
|
+
# element.gsub!(@@pattern_dq_2,DOUBLE_QUATATION)
|
4141
|
+
#end
|
4044
4142
|
#「 」<-「 」
|
4045
|
-
if element.include?(NBSP_2) then
|
4046
|
-
|
4047
|
-
end
|
4143
|
+
#if element.include?(NBSP_2) then
|
4144
|
+
# element.gsub!(@@pattern_space_2,SPACE)
|
4145
|
+
#end
|
4048
4146
|
#「&」<-「&」
|
4049
|
-
if element.include?(AND_2) then
|
4050
|
-
|
4051
|
-
end
|
4052
|
-
|
4147
|
+
#if element.include?(AND_2) then
|
4148
|
+
# element.gsub!(@@pattern_and_2,AND_1)
|
4149
|
+
#end
|
4150
|
+
element.gsub!(@@pattern_unescape){
|
4151
|
+
case $1
|
4152
|
+
when 'amp' then '&'
|
4153
|
+
when 'quot' then '"'
|
4154
|
+
when 'apos' then '\''
|
4155
|
+
when 'gt' then '>'
|
4156
|
+
when 'lt' then '<'
|
4157
|
+
when 'nbsp' then ' '
|
4158
|
+
end
|
4159
|
+
}
|
4160
|
+
|
4053
4161
|
element
|
4054
4162
|
end
|
4055
4163
|
private :unescape
|
@@ -4078,6 +4186,17 @@ module Meteor
|
|
4078
4186
|
#
|
4079
4187
|
class ParserImpl < Meteor::Core::Kernel
|
4080
4188
|
|
4189
|
+
TABLE_FOR_ESCAPE_ = {
|
4190
|
+
'&' => '&',
|
4191
|
+
'"' => '"',
|
4192
|
+
'\'' => ''',
|
4193
|
+
'<' => '<',
|
4194
|
+
'>' => '>',
|
4195
|
+
}
|
4196
|
+
|
4197
|
+
PATTERN_ESCAPE = "[&\"'<>]"
|
4198
|
+
PATTERN_UNESCAPE = '&(amp|quot|apos|gt|lt);'
|
4199
|
+
|
4081
4200
|
@@pattern_and_1 = Regexp.new(AND_1)
|
4082
4201
|
@@pattern_lt_1 = Regexp.new(LT_1)
|
4083
4202
|
@@pattern_gt_1 = Regexp.new(GT_1)
|
@@ -4088,7 +4207,10 @@ module Meteor
|
|
4088
4207
|
@@pattern_dq_2 = Regexp.new(QO_2)
|
4089
4208
|
@@pattern_ap_2 = Regexp.new(AP_2)
|
4090
4209
|
@@pattern_and_2 = Regexp.new(AND_2)
|
4091
|
-
|
4210
|
+
|
4211
|
+
@@pattern_escape = Regexp.new(PATTERN_ESCAPE)
|
4212
|
+
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
4213
|
+
|
4092
4214
|
@@pattern_set_mono1 = Regexp.new(SET_MONO_1)
|
4093
4215
|
|
4094
4216
|
#
|
@@ -4177,25 +4299,29 @@ module Meteor
|
|
4177
4299
|
|
4178
4300
|
def escape(element)
|
4179
4301
|
#特殊文字の置換
|
4180
|
-
|
4181
|
-
|
4182
|
-
element.
|
4183
|
-
|
4184
|
-
|
4185
|
-
|
4186
|
-
element.
|
4187
|
-
|
4188
|
-
|
4189
|
-
|
4190
|
-
element.
|
4191
|
-
|
4192
|
-
|
4193
|
-
|
4194
|
-
element.
|
4195
|
-
|
4196
|
-
|
4197
|
-
|
4198
|
-
element.
|
4302
|
+
if RUBY_VERSION < '1.9.0' then
|
4303
|
+
#「&」->「&」
|
4304
|
+
if element.include?(AND_1) then
|
4305
|
+
element.gsub!(@@pattern_and_1,AND_2)
|
4306
|
+
end
|
4307
|
+
#「<」->「<」
|
4308
|
+
if element.include?(LT_1) then
|
4309
|
+
element.gsub!(@@pattern_lt_1,LT_2)
|
4310
|
+
end
|
4311
|
+
#「>」->「>」
|
4312
|
+
if element.include?(GT_1) then
|
4313
|
+
element.gsub!(@@pattern_gt_1,GT_2)
|
4314
|
+
end
|
4315
|
+
#「"」->「"」
|
4316
|
+
if element.include?(DOUBLE_QUATATION) then
|
4317
|
+
element.gsub!(@@pattern_dq_1,QO_2)
|
4318
|
+
end
|
4319
|
+
#「'」->「'」
|
4320
|
+
if element.include?(AP_1) then
|
4321
|
+
element.gsub!(@@pattern_ap_1,AP_2)
|
4322
|
+
end
|
4323
|
+
else
|
4324
|
+
element.gsub!(@@pattern_escape,TABLE_FOR_ESCAPE_)
|
4199
4325
|
end
|
4200
4326
|
|
4201
4327
|
element
|
@@ -4209,26 +4335,38 @@ module Meteor
|
|
4209
4335
|
|
4210
4336
|
def unescape(element)
|
4211
4337
|
#特殊文字の置換
|
4212
|
-
|
4213
|
-
|
4214
|
-
|
4215
|
-
|
4216
|
-
|
4217
|
-
|
4218
|
-
|
4219
|
-
|
4220
|
-
|
4221
|
-
|
4222
|
-
|
4223
|
-
|
4224
|
-
|
4225
|
-
|
4226
|
-
|
4227
|
-
|
4228
|
-
|
4229
|
-
|
4230
|
-
|
4231
|
-
|
4338
|
+
#if RUBY_VERSION < '1.9.0' then
|
4339
|
+
# #「<」<-「<」
|
4340
|
+
# if element.include?(LT_2) then
|
4341
|
+
# element.gsub!(@@pattern_lt_2,LT_1)
|
4342
|
+
# end
|
4343
|
+
# #「>」<-「>」
|
4344
|
+
# if element.include?(GT_2) then
|
4345
|
+
# element.gsub!(@@pattern_gt_2,GT_1)
|
4346
|
+
# end
|
4347
|
+
# #「"」<-「"」
|
4348
|
+
# if element.include?(QO_2) then
|
4349
|
+
# element.gsub!(@@pattern_dq_2,DOUBLE_QUATATION)
|
4350
|
+
# end
|
4351
|
+
# #「'」<-「'」
|
4352
|
+
# if element.include?(AP_2) then
|
4353
|
+
# element.gsub!(@@pattern_ap_2,AP_1)
|
4354
|
+
# end
|
4355
|
+
# #「&」<-「&」
|
4356
|
+
# if element.include?(AND_2) then
|
4357
|
+
# element.gsub!(@@pattern_and_2,AND_1)
|
4358
|
+
# end
|
4359
|
+
#else
|
4360
|
+
element.gsub!(@@pattern_unescape){
|
4361
|
+
case $1
|
4362
|
+
when 'amp' then '&'
|
4363
|
+
when 'quot' then '"'
|
4364
|
+
when 'apos' then '\''
|
4365
|
+
when 'gt' then '>'
|
4366
|
+
when 'lt' then '<'
|
4367
|
+
end
|
4368
|
+
}
|
4369
|
+
#end
|
4232
4370
|
|
4233
4371
|
element
|
4234
4372
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asip-meteor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.0.
|
4
|
+
version: 0.9.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- asip
|
@@ -9,7 +9,7 @@ autorequire: meteor
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-11-15 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|