Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
mycard
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
syntax_j
mycard
Commits
1e69ab00
Commit
1e69ab00
authored
Mar 25, 2014
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix中文验证
parent
b0f40b46
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
279 additions
and
2 deletions
+279
-2
app/candy/base64.js
app/candy/base64.js
+216
-0
app/candy/candy.fix.js
app/candy/candy.fix.js
+62
-1
app/index.html
app/index.html
+1
-1
No files found.
app/candy/base64.js
0 → 100644
View file @
1e69ab00
/*
Copyright (c) 2008 Fred Palmer fred.palmer_at_gmail.com
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
function
StringBuffer
()
{
this
.
buffer
=
[];
}
StringBuffer
.
prototype
.
append
=
function
append
(
string
)
{
this
.
buffer
.
push
(
string
);
return
this
;
};
StringBuffer
.
prototype
.
toString
=
function
toString
()
{
return
this
.
buffer
.
join
(
""
);
};
var
Base64
=
{
codex
:
"
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
"
,
encode
:
function
(
input
)
{
var
output
=
new
StringBuffer
();
var
enumerator
=
new
Utf8EncodeEnumerator
(
input
);
while
(
enumerator
.
moveNext
())
{
var
chr1
=
enumerator
.
current
;
enumerator
.
moveNext
();
var
chr2
=
enumerator
.
current
;
enumerator
.
moveNext
();
var
chr3
=
enumerator
.
current
;
var
enc1
=
chr1
>>
2
;
var
enc2
=
((
chr1
&
3
)
<<
4
)
|
(
chr2
>>
4
);
var
enc3
=
((
chr2
&
15
)
<<
2
)
|
(
chr3
>>
6
);
var
enc4
=
chr3
&
63
;
if
(
isNaN
(
chr2
))
{
enc3
=
enc4
=
64
;
}
else
if
(
isNaN
(
chr3
))
{
enc4
=
64
;
}
output
.
append
(
this
.
codex
.
charAt
(
enc1
)
+
this
.
codex
.
charAt
(
enc2
)
+
this
.
codex
.
charAt
(
enc3
)
+
this
.
codex
.
charAt
(
enc4
));
}
return
output
.
toString
();
},
decode
:
function
(
input
)
{
var
output
=
new
StringBuffer
();
var
enumerator
=
new
Base64DecodeEnumerator
(
input
);
while
(
enumerator
.
moveNext
())
{
var
charCode
=
enumerator
.
current
;
if
(
charCode
<
128
)
output
.
append
(
String
.
fromCharCode
(
charCode
));
else
if
((
charCode
>
191
)
&&
(
charCode
<
224
))
{
enumerator
.
moveNext
();
var
charCode2
=
enumerator
.
current
;
output
.
append
(
String
.
fromCharCode
(((
charCode
&
31
)
<<
6
)
|
(
charCode2
&
63
)));
}
else
{
enumerator
.
moveNext
();
var
charCode2
=
enumerator
.
current
;
enumerator
.
moveNext
();
var
charCode3
=
enumerator
.
current
;
output
.
append
(
String
.
fromCharCode
(((
charCode
&
15
)
<<
12
)
|
((
charCode2
&
63
)
<<
6
)
|
(
charCode3
&
63
)));
}
}
return
output
.
toString
();
}
}
function
Utf8EncodeEnumerator
(
input
)
{
this
.
_input
=
input
;
this
.
_index
=
-
1
;
this
.
_buffer
=
[];
}
Utf8EncodeEnumerator
.
prototype
=
{
current
:
Number
.
NaN
,
moveNext
:
function
()
{
if
(
this
.
_buffer
.
length
>
0
)
{
this
.
current
=
this
.
_buffer
.
shift
();
return
true
;
}
else
if
(
this
.
_index
>=
(
this
.
_input
.
length
-
1
))
{
this
.
current
=
Number
.
NaN
;
return
false
;
}
else
{
var
charCode
=
this
.
_input
.
charCodeAt
(
++
this
.
_index
);
// "\r\n" -> "\n"
//
if
((
charCode
==
13
)
&&
(
this
.
_input
.
charCodeAt
(
this
.
_index
+
1
)
==
10
))
{
charCode
=
10
;
this
.
_index
+=
2
;
}
if
(
charCode
<
128
)
{
this
.
current
=
charCode
;
}
else
if
((
charCode
>
127
)
&&
(
charCode
<
2048
))
{
this
.
current
=
(
charCode
>>
6
)
|
192
;
this
.
_buffer
.
push
((
charCode
&
63
)
|
128
);
}
else
{
this
.
current
=
(
charCode
>>
12
)
|
224
;
this
.
_buffer
.
push
(((
charCode
>>
6
)
&
63
)
|
128
);
this
.
_buffer
.
push
((
charCode
&
63
)
|
128
);
}
return
true
;
}
}
}
function
Base64DecodeEnumerator
(
input
)
{
this
.
_input
=
input
;
this
.
_index
=
-
1
;
this
.
_buffer
=
[];
}
Base64DecodeEnumerator
.
prototype
=
{
current
:
64
,
moveNext
:
function
()
{
if
(
this
.
_buffer
.
length
>
0
)
{
this
.
current
=
this
.
_buffer
.
shift
();
return
true
;
}
else
if
(
this
.
_index
>=
(
this
.
_input
.
length
-
1
))
{
this
.
current
=
64
;
return
false
;
}
else
{
var
enc1
=
Base64
.
codex
.
indexOf
(
this
.
_input
.
charAt
(
++
this
.
_index
));
var
enc2
=
Base64
.
codex
.
indexOf
(
this
.
_input
.
charAt
(
++
this
.
_index
));
var
enc3
=
Base64
.
codex
.
indexOf
(
this
.
_input
.
charAt
(
++
this
.
_index
));
var
enc4
=
Base64
.
codex
.
indexOf
(
this
.
_input
.
charAt
(
++
this
.
_index
));
var
chr1
=
(
enc1
<<
2
)
|
(
enc2
>>
4
);
var
chr2
=
((
enc2
&
15
)
<<
4
)
|
(
enc3
>>
2
);
var
chr3
=
((
enc3
&
3
)
<<
6
)
|
enc4
;
this
.
current
=
chr1
;
if
(
enc3
!=
64
)
this
.
_buffer
.
push
(
chr2
);
if
(
enc4
!=
64
)
this
.
_buffer
.
push
(
chr3
);
return
true
;
}
}
};
app/candy/candy.fix.js
View file @
1e69ab00
...
...
@@ -358,4 +358,65 @@ Candy.View = function(self, $) {
return
_options
;
};
return
self
;
}(
Candy
.
View
||
{},
jQuery
);
\ No newline at end of file
}(
Candy
.
View
||
{},
jQuery
);
//中文验证,看起来SHA1、MD5、PLAIN都对中文支持有问题。通过更换base64库可以修复PLAIN,然后在这里只允许PLAIN认证
Strophe
.
Connection
.
prototype
.
_connect_cb
=
function
(
req
,
_callback
,
raw
)
{
Strophe
.
info
(
"
_connect_cb was called
"
);
this
.
connected
=
true
;
var
bodyWrap
=
this
.
_proto
.
_reqToData
(
req
);
if
(
!
bodyWrap
)
{
return
;
}
if
(
this
.
xmlInput
!==
Strophe
.
Connection
.
prototype
.
xmlInput
)
{
if
(
bodyWrap
.
nodeName
===
this
.
_proto
.
strip
&&
bodyWrap
.
childNodes
.
length
)
{
this
.
xmlInput
(
bodyWrap
.
childNodes
[
0
]);
}
else
{
this
.
xmlInput
(
bodyWrap
);
}
}
if
(
this
.
rawInput
!==
Strophe
.
Connection
.
prototype
.
rawInput
)
{
if
(
raw
)
{
this
.
rawInput
(
raw
);
}
else
{
this
.
rawInput
(
Strophe
.
serialize
(
bodyWrap
));
}
}
var
conncheck
=
this
.
_proto
.
_connect_cb
(
bodyWrap
);
if
(
conncheck
===
Strophe
.
Status
.
CONNFAIL
)
{
return
;
}
this
.
_authentication
.
sasl_scram_sha1
=
false
;
this
.
_authentication
.
sasl_plain
=
false
;
this
.
_authentication
.
sasl_digest_md5
=
false
;
this
.
_authentication
.
sasl_anonymous
=
false
;
this
.
_authentication
.
legacy_auth
=
false
;
// Check for the stream:features tag
var
hasFeatures
=
bodyWrap
.
getElementsByTagName
(
"
stream:features
"
).
length
>
0
;
if
(
!
hasFeatures
)
{
hasFeatures
=
bodyWrap
.
getElementsByTagName
(
"
features
"
).
length
>
0
;
}
var
mechanisms
=
bodyWrap
.
getElementsByTagName
(
"
mechanism
"
);
var
matched
=
[];
var
i
,
mech
,
auth_str
,
hashed_auth_str
,
found_authentication
=
false
;
if
(
!
hasFeatures
)
{
this
.
_proto
.
_no_auth_received
(
_callback
);
return
;
}
if
(
mechanisms
.
length
>
0
)
{
for
(
i
=
0
;
i
<
mechanisms
.
length
;
i
++
)
{
mech
=
Strophe
.
getText
(
mechanisms
[
i
]);
if
(
mech
==
'
SCRAM-SHA-1
'
||
mech
==
'
DIGEST-MD5
'
)
continue
if
(
this
.
mechanisms
[
mech
])
matched
.
push
(
this
.
mechanisms
[
mech
]);
}
}
this
.
_authentication
.
legacy_auth
=
bodyWrap
.
getElementsByTagName
(
"
auth
"
).
length
>
0
;
found_authentication
=
this
.
_authentication
.
legacy_auth
||
matched
.
length
>
0
;
if
(
!
found_authentication
)
{
this
.
_proto
.
_no_auth_received
(
_callback
);
return
;
}
console
.
log
(
matched
)
if
(
this
.
do_authentication
!==
false
)
this
.
authenticate
(
matched
);
}
\ No newline at end of file
app/index.html
View file @
1e69ab00
...
...
@@ -89,7 +89,7 @@
</div>
</div>
<div
class=
"row"
>
<iframe
id=
"candy"
src=
"candy/index.html?bosh=http://localhost:5280/http-bind&jid=
zh99998@my-card.in&password=zh112998
"
nwdisable
></iframe>
<iframe
id=
"candy"
src=
"candy/index.html?bosh=http://localhost:5280/http-bind&jid=
毛玉测试@my-card.in&password=123456
"
nwdisable
></iframe>
</div>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment