Fix a crasher in the serializer

A tail containing regexp syntax (a ? in [[:en:Main Page]]) would crash the
serializer. Use substr instead.

Change-Id: I8519aec9c07dfe31893d676b1c936a42d2af74a0
This commit is contained in:
Gabriel Wicke 2012-06-04 00:00:54 +02:00
parent d01581c380
commit 4533c274ca

View file

@ -414,7 +414,9 @@ WSP._serializeToken = function ( state, token ) {
state.precedingNewlineCount = 0; state.precedingNewlineCount = 0;
} }
if ( ! dropContent || ! state.dropContent ) { if ( ! dropContent || ! state.dropContent ) {
if (state.linkTail) res = res.replace(new RegExp(state.linkTail + "$"), ""); if (state.linkTail && res.substr(- state.linkTail.length) === state.linkTail) {
res = res.substr(0, res.length - state.linkTail.length);
}
state.chunkCB( res ); state.chunkCB( res );
} }
} }