fix 404 when reacting with Keycap Number Sign

The Unicode sequence for this emoji starts with an
ASCII # character, which the browser's URI parser
truncates before sending the request to the
backend.
This commit is contained in:
fef 2022-12-11 13:26:23 +00:00 committed by Jeremy Kescher
parent 8d9105e4c2
commit 5ec5a782d4
No known key found for this signature in database
GPG key ID: 80A419A7A613DFA4
2 changed files with 8 additions and 4 deletions

View file

@ -416,7 +416,9 @@ export const addReaction = (statusId, name, url) => (dispatch, getState) => {
dispatch(addReactionRequest(statusId, name, url));
}
api(getState).post(`/api/v1/statuses/${statusId}/react/${name}`).then(() => {
// encodeURIComponent is required for the Keycap Number Sign emoji, see:
// <https://github.com/glitch-soc/mastodon/pull/1980#issuecomment-1345538932>
api(getState).post(`/api/v1/statuses/${statusId}/react/${encodeURIComponent(name)}`).then(() => {
dispatch(addReactionSuccess(statusId, name));
}).catch(err => {
if (!alreadyAdded) {
@ -448,7 +450,7 @@ export const addReactionFail = (statusId, name, error) => ({
export const removeReaction = (statusId, name) => (dispatch, getState) => {
dispatch(removeReactionRequest(statusId, name));
api(getState).post(`/api/v1/statuses/${statusId}/unreact/${name}`).then(() => {
api(getState).post(`/api/v1/statuses/${statusId}/unreact/${encodeURIComponent(name)}`).then(() => {
dispatch(removeReactionSuccess(statusId, name));
}).catch(err => {
dispatch(removeReactionFail(statusId, name, err));

View file

@ -436,7 +436,9 @@ export const addReaction = (statusId, name, url) => (dispatch, getState) => {
dispatch(addReactionRequest(statusId, name, url));
}
api(getState).post(`/api/v1/statuses/${statusId}/react/${name}`).then(() => {
// encodeURIComponent is required for the Keycap Number Sign emoji, see:
// <https://github.com/glitch-soc/mastodon/pull/1980#issuecomment-1345538932>
api(getState).post(`/api/v1/statuses/${statusId}/react/${encodeURIComponent(name)}`).then(() => {
dispatch(addReactionSuccess(statusId, name));
}).catch(err => {
if (!alreadyAdded) {
@ -468,7 +470,7 @@ export const addReactionFail = (statusId, name, error) => ({
export const removeReaction = (statusId, name) => (dispatch, getState) => {
dispatch(removeReactionRequest(statusId, name));
api(getState).post(`/api/v1/statuses/${statusId}/unreact/${name}`).then(() => {
api(getState).post(`/api/v1/statuses/${statusId}/unreact/${encodeURIComponent(name)}`).then(() => {
dispatch(removeReactionSuccess(statusId, name));
}).catch(err => {
dispatch(removeReactionFail(statusId, name, err));