@@ -27,7 +27,7 @@ define([
27
27
describe ( 'wysiwygAdapter' , function ( ) {
28
28
describe ( 'encoding and decoding directives' , function ( ) {
29
29
function runTests ( decodedHtml , encodedHtml ) {
30
- var encodedHtmlWithForwardSlashInImgSrc = encodedHtml . replace ( ' src="([^"]+)' , 'src="$1/" ' ) ;
30
+ var encodedHtmlWithForwardSlashInImgSrc = encodedHtml . replace ( / s r c = " ( (?: (? ! " | \\ \? ) . ) * ) / , 'src="$1/' ) ;
31
31
32
32
describe ( '"encodeDirectives" method' , function ( ) {
33
33
it ( 'converts media directive img src to directive URL' , function ( ) {
@@ -47,48 +47,93 @@ define([
47
47
it ( 'converts directive URL img src with a trailing forward slash ' +
48
48
'to media url without a trailing forward slash' ,
49
49
function ( ) {
50
+ expect ( encodedHtmlWithForwardSlashInImgSrc ) . not . toEqual ( encodedHtml ) ;
50
51
expect ( obj . decodeDirectives ( encodedHtmlWithForwardSlashInImgSrc ) ) . toEqual ( decodedHtml ) ;
51
52
}
52
53
) ;
53
54
} ) ;
54
55
}
55
56
56
- describe ( 'without secret key' , function ( ) {
57
- var decodedHtml = '<p>' +
58
- '<img src="{{media url="wysiwyg/banana.jpg"}}" alt="" width="612" height="459"></p>' ,
59
- encodedHtml = '<p>' +
60
- '<img src="http://example.com/admin/cms/wysiwyg/directive/___directive' +
61
- '/e3ttZWRpYSB1cmw9Ind5c2l3eWcvYmFuYW5hLmpwZyJ9fQ%2C%2C" alt="" width="612" height="459">' +
62
- '</p>' ;
63
-
64
- beforeEach ( function ( ) {
65
- obj . initialize ( 'id' , {
66
- 'directives_url' : 'http://example.com/admin/cms/wysiwyg/directive/'
57
+ describe ( 'without SID in directive query string' , function ( ) {
58
+ describe ( 'without secret key' , function ( ) {
59
+ var decodedHtml = '<p>' +
60
+ '<img src="{{media url="wysiwyg/banana.jpg"}}" alt="" width="612" height="459"></p>' ,
61
+ encodedHtml = '<p>' +
62
+ '<img src="http://example.com/admin/cms/wysiwyg/directive/___directive' +
63
+ '/e3ttZWRpYSB1cmw9Ind5c2l3eWcvYmFuYW5hLmpwZyJ9fQ%2C%2C" alt="" width="612" height="459">' +
64
+ '</p>' ;
65
+
66
+ beforeEach ( function ( ) {
67
+ obj . initialize ( 'id' , {
68
+ 'directives_url' : 'http://example.com/admin/cms/wysiwyg/directive/'
69
+ } ) ;
67
70
} ) ;
71
+
72
+ runTests ( decodedHtml , encodedHtml ) ;
68
73
} ) ;
69
74
70
- runTests ( decodedHtml , encodedHtml ) ;
75
+ describe ( 'with secret key' , function ( ) {
76
+ var decodedHtml = '<p>' +
77
+ '<img src="{{media url="wysiwyg/banana.jpg"}}" alt="" width="612" height="459"></p>' ,
78
+ encodedHtml = '<p>' +
79
+ '<img src="http://example.com/admin/cms/wysiwyg/directive/___directive' +
80
+ '/e3ttZWRpYSB1cmw9Ind5c2l3eWcvYmFuYW5hLmpwZyJ9fQ%2C%2C/key/' +
81
+ '5552655d13a141099d27f5d5b0c58869423fd265687167da12cad2bb39aa9a58" ' +
82
+ 'alt="" width="612" height="459">' +
83
+ '</p>' ,
84
+ directiveUrl = 'http://example.com/admin/cms/wysiwyg/directive/key/' +
85
+ '5552655d13a141099d27f5d5b0c58869423fd265687167da12cad2bb39aa9a58/' ;
86
+
87
+ beforeEach ( function ( ) {
88
+ obj . initialize ( 'id' , {
89
+ 'directives_url' : directiveUrl
90
+ } ) ;
91
+ } ) ;
92
+
93
+ runTests ( decodedHtml , encodedHtml ) ;
94
+ } ) ;
71
95
} ) ;
72
96
73
- describe ( 'with secret key ' , function ( ) {
74
- var decodedHtml = '<p>' +
75
- '<img src="{{media url="wysiwyg/banana.jpg"}}" alt="" width="612" height="459"></ p>',
76
- encodedHtml = '< p>' +
77
- '<img src="http://example.com/admin/cms/wysiwyg/directive/___directive ' +
78
- '/e3ttZWRpYSB1cmw9Ind5c2l3eWcvYmFuYW5hLmpwZyJ9fQ%2C%2C/key/ ' +
79
- '5552655d13a141099d27f5d5b0c58869423fd265687167da12cad2bb39aa9a58 " ' +
80
- 'alt="" width="612" height="459">' +
81
- '</p>' ,
82
- directiveUrl = 'http://example.com/admin/cms/wysiwyg/directive/key/' +
83
- '5552655d13a141099d27f5d5b0c58869423fd265687167da12cad2bb39aa9a58/' ;
84
-
85
- beforeEach ( function ( ) {
86
- obj . initialize ( 'id' , {
87
- 'directives_url' : directiveUrl
97
+ describe ( 'with SID in directive query string ' , function ( ) {
98
+ describe ( 'without secret key' , function ( ) {
99
+ var decodedHtml = '< p>' +
100
+ '<img src="{{media url="wysiwyg/banana.jpg"}}" alt="" width="612" height="459"></ p>',
101
+ encodedHtml = '<p> ' +
102
+ '<img src="http://example.com/admin/cms/wysiwyg/directive/___directive ' +
103
+ '/e3ttZWRpYSB1cmw9Ind5c2l3eWcvYmFuYW5hLmpwZyJ9fQ%2C%2C?SID=something " ' +
104
+ 'alt="" width="612" height="459">' +
105
+ '</p>' ,
106
+ directiveUrl = 'http://example.com/admin/cms/wysiwyg/directive?SID=something' ;
107
+
108
+ beforeEach ( function ( ) {
109
+ obj . initialize ( 'id' , {
110
+ 'directives_url' : directiveUrl
111
+ } ) ;
88
112
} ) ;
113
+
114
+ runTests ( decodedHtml , encodedHtml ) ;
89
115
} ) ;
90
116
91
- runTests ( decodedHtml , encodedHtml ) ;
117
+ describe ( 'with secret key' , function ( ) {
118
+ var decodedHtml = '<p>' +
119
+ '<img src="{{media url="wysiwyg/banana.jpg"}}" alt="" width="612" height="459"></p>' ,
120
+ encodedHtml = '<p>' +
121
+ '<img src="http://example.com/admin/cms/wysiwyg/directive/___directive' +
122
+ '/e3ttZWRpYSB1cmw9Ind5c2l3eWcvYmFuYW5hLmpwZyJ9fQ%2C%2C/key/' +
123
+ '5552655d13a141099d27f5d5b0c58869423fd265687167da12cad2bb39aa9a58?SID=something" ' +
124
+ 'alt="" width="612" height="459">' +
125
+ '</p>' ,
126
+ directiveUrl = 'http://example.com/admin/cms/wysiwyg/directive/key/' +
127
+ '5552655d13a141099d27f5d5b0c58869423fd265687167da12cad2bb39aa9a58?SID=something' ;
128
+
129
+ beforeEach ( function ( ) {
130
+ obj . initialize ( 'id' , {
131
+ 'directives_url' : directiveUrl
132
+ } ) ;
133
+ } ) ;
134
+
135
+ runTests ( decodedHtml , encodedHtml ) ;
136
+ } ) ;
92
137
} ) ;
93
138
} ) ;
94
139
} ) ;
0 commit comments