mirror of https://github.com/zulip/zulip.git
popovers: Encode brackets in URI to avoid conflict with markdown links.
This fixes an issue where one could end up with a `(` in the markdown syntax for a link after copy-pasting this, which doesn't work in markdown. Fixes #12579.
This commit is contained in:
parent
b6ce366d61
commit
0253ef12c6
|
@ -9,6 +9,9 @@ zrequire('presence');
|
||||||
zrequire('buddy_data');
|
zrequire('buddy_data');
|
||||||
zrequire('user_status');
|
zrequire('user_status');
|
||||||
zrequire('settings_org');
|
zrequire('settings_org');
|
||||||
|
zrequire('feature_flags');
|
||||||
|
zrequire('message_edit');
|
||||||
|
zrequire('util');
|
||||||
|
|
||||||
var noop = function () {};
|
var noop = function () {};
|
||||||
$.fn.popover = noop; // this will get wrapped by our code
|
$.fn.popover = noop; // this will get wrapped by our code
|
||||||
|
@ -40,6 +43,8 @@ set_global('stream_popover', {
|
||||||
restore_stream_list_size: noop,
|
restore_stream_list_size: noop,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
set_global('stream_data', {});
|
||||||
|
|
||||||
set_global('ClipboardJS', function (sel) {
|
set_global('ClipboardJS', function (sel) {
|
||||||
assert.equal(sel, '.copy_link');
|
assert.equal(sel, '.copy_link');
|
||||||
});
|
});
|
||||||
|
@ -59,6 +64,17 @@ var me = {
|
||||||
timezone: 'US/Pacific',
|
timezone: 'US/Pacific',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var target = $.create('click target');
|
||||||
|
target.offset = () => {
|
||||||
|
return {
|
||||||
|
top: 10,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
var e = {
|
||||||
|
stopPropagation: noop,
|
||||||
|
};
|
||||||
|
|
||||||
function initialize_people() {
|
function initialize_people() {
|
||||||
people.init();
|
people.init();
|
||||||
people.add_in_realm(me);
|
people.add_in_realm(me);
|
||||||
|
@ -94,14 +110,11 @@ function make_image_stubber() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
run_test('sender_hover', () => {
|
popovers.register_click_handlers();
|
||||||
popovers.register_click_handlers();
|
|
||||||
|
|
||||||
|
run_test('sender_hover', () => {
|
||||||
var selection = ".sender_name, .sender_name-in-status, .inline_profile_picture";
|
var selection = ".sender_name, .sender_name-in-status, .inline_profile_picture";
|
||||||
var handler = $('#main_div').get_on_handler('click', selection);
|
var handler = $('#main_div').get_on_handler('click', selection);
|
||||||
var e = {
|
|
||||||
stopPropagation: noop,
|
|
||||||
};
|
|
||||||
|
|
||||||
var message = {
|
var message = {
|
||||||
id: 999,
|
id: 999,
|
||||||
|
@ -113,14 +126,6 @@ run_test('sender_hover', () => {
|
||||||
status_text: 'on the beach',
|
status_text: 'on the beach',
|
||||||
});
|
});
|
||||||
|
|
||||||
var target = $.create('click target');
|
|
||||||
|
|
||||||
target.offset = () => {
|
|
||||||
return {
|
|
||||||
top: 10,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
rows.id = () => message.id;
|
rows.id = () => message.id;
|
||||||
|
|
||||||
current_msg_list.get = (msg_id) => {
|
current_msg_list.get = (msg_id) => {
|
||||||
|
@ -192,3 +197,54 @@ run_test('sender_hover', () => {
|
||||||
|
|
||||||
// todo: load image
|
// todo: load image
|
||||||
});
|
});
|
||||||
|
|
||||||
|
run_test('actions_popover', () => {
|
||||||
|
var handler = $('#main_div').get_on_handler('click', '.actions_hover');
|
||||||
|
|
||||||
|
window.location = {
|
||||||
|
protocol: 'http:',
|
||||||
|
host: 'chat.zulip.org',
|
||||||
|
pathname: '/',
|
||||||
|
};
|
||||||
|
|
||||||
|
var message = {
|
||||||
|
id: 999,
|
||||||
|
topic: 'Actions (1)',
|
||||||
|
type: 'stream',
|
||||||
|
stream_id: 123,
|
||||||
|
};
|
||||||
|
|
||||||
|
current_msg_list.get = (msg_id) => {
|
||||||
|
assert.equal(msg_id, message.id);
|
||||||
|
return message;
|
||||||
|
};
|
||||||
|
|
||||||
|
message_edit.get_editability = () => 4;
|
||||||
|
|
||||||
|
stream_data.id_to_slug = (stream_id) => {
|
||||||
|
assert.equal(stream_id, 123);
|
||||||
|
return 'Bracket ( stream';
|
||||||
|
};
|
||||||
|
|
||||||
|
target.closest = (sel) => {
|
||||||
|
assert.equal(sel, '.message_row');
|
||||||
|
return {
|
||||||
|
toggleClass: noop,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
templates.render = function (fn, opts) {
|
||||||
|
// TODO: Test all the properties of the popover
|
||||||
|
switch (fn) {
|
||||||
|
case 'actions_popover_content':
|
||||||
|
assert.equal(
|
||||||
|
opts.conversation_time_uri,
|
||||||
|
'http://chat.zulip.org/#narrow/stream/Bracket.20%28.20stream/topic/Actions.20%281%29/near/999');
|
||||||
|
return 'actions-content';
|
||||||
|
default:
|
||||||
|
throw Error('unrecognized template: ' + fn);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
handler.call(target, e);
|
||||||
|
});
|
||||||
|
|
|
@ -431,6 +431,10 @@ exports.toggle_actions_popover = function (element, id) {
|
||||||
editability === message_edit.editability_types.TOPIC_ONLY;
|
editability === message_edit.editability_types.TOPIC_ONLY;
|
||||||
var should_display_quote_and_reply = message.content !== '<p>(deleted)</p>';
|
var should_display_quote_and_reply = message.content !== '<p>(deleted)</p>';
|
||||||
|
|
||||||
|
var conversation_time_uri = hash_util.by_conversation_and_time_uri(message)
|
||||||
|
.replace(/\(/g, '%28')
|
||||||
|
.replace(/\)/g, '%29');
|
||||||
|
|
||||||
var should_display_delete_option = message_edit.get_deletability(message);
|
var should_display_delete_option = message_edit.get_deletability(message);
|
||||||
var args = {
|
var args = {
|
||||||
message_id: message.id,
|
message_id: message.id,
|
||||||
|
@ -445,7 +449,7 @@ exports.toggle_actions_popover = function (element, id) {
|
||||||
should_display_uncollapse: should_display_uncollapse,
|
should_display_uncollapse: should_display_uncollapse,
|
||||||
should_display_add_reaction_option: message.sent_by_me,
|
should_display_add_reaction_option: message.sent_by_me,
|
||||||
should_display_edit_history_option: should_display_edit_history_option,
|
should_display_edit_history_option: should_display_edit_history_option,
|
||||||
conversation_time_uri: hash_util.by_conversation_and_time_uri(message),
|
conversation_time_uri: conversation_time_uri,
|
||||||
narrowed: narrow_state.active(),
|
narrowed: narrow_state.active(),
|
||||||
should_display_delete_option: should_display_delete_option,
|
should_display_delete_option: should_display_delete_option,
|
||||||
should_display_reminder_option: feature_flags.reminders_in_message_action_menu,
|
should_display_reminder_option: feature_flags.reminders_in_message_action_menu,
|
||||||
|
|
|
@ -41,6 +41,7 @@ enforce_fully_covered = {
|
||||||
# 'static/js/composebox_typeahead.js',
|
# 'static/js/composebox_typeahead.js',
|
||||||
'static/js/dict.ts',
|
'static/js/dict.ts',
|
||||||
'static/js/emoji.js',
|
'static/js/emoji.js',
|
||||||
|
'static/js/feature_flags.js',
|
||||||
'static/js/fenced_code.js',
|
'static/js/fenced_code.js',
|
||||||
'static/js/fetch_status.js',
|
'static/js/fetch_status.js',
|
||||||
'static/js/filter.js',
|
'static/js/filter.js',
|
||||||
|
|
Loading…
Reference in New Issue