The client might have disconnected between callbacks so don't try to
write to the session before checking this. The main callback of this
function now has a single check at its top.
Removed a redundant check halfway through the callback.
Also normalized use of client.id for the session index instead of a mix of
client.id and sessionId.
Added some explanatory comments.
We had a problem with the server running out of stack space if a client
submitted a changeset based on a revision more than about 1000 revs old.
(944 was our cutoff but yours may vary). This happened in the wild with
about 30 people editing via flaky wifi. A disconnected client would try
to submit a fairly old changeset when reconnecting, and a few minutes
was enough for 30 people to generate that many revs.
The stack kept growing because pad.getRevisionChangeset was being answered
from the cache, so no I/O interrupted the callback chain. (This was seen with
mysql, I don't know about other backends.)
This patch forces a nextTick every 200 revisions to solve this problem.
When stress testing etherpad-lite we occasionally got this error:
TypeError: Cannot read property 'author' of undefined
at /home/etherpad/etherpad-lite/src/node/handler/PadMessageHandler.js:556:47
handleUserChanges was accessing sessioninfos[client.id].author in a callback,
after spending some time in the loop that updates the changeset to the
latest revision. It's possible for a disconnect request to be processed
during that loop so the session might no longer be there.
This patch fixes it by looking up the author at the start of the function.
The utility functions colorutils.js assume that background colors are in
CSS hex format, so require userColor to do the same, rather than
allowing inputs like "red" and "rgba(...)", to insure that inversion
checks will succeed.
Use 'transparent' instead of 'white' as a reference color for validating
CSS color values. Presumably, a user setting a userColor wants some
color other than 'transparent' if they are setting it (they could always
duplicate the background's color if not).
Add a URL parameter which sets the initial color for a user, e.g.:
http://example.com/p/mypad?userColor=%2300ff00
Sanitize the given color value to ensure that it's a valid css value
(could be any supported CSS color format -- #fff, rgba(), "red", etc).
Shortly after rejoining a pad, the server responds with a USER_NEWINFO
message which may contain an old color value; however, this message
arrives after we have set and sent the new color value to the server.
To avoid this race condition, if the query parameter has been set,
ignore the color value in a USER_NEWINFO message which matches our user
ID.
moved inInternationalComposition from Ace2Inner to top window
fix bindTheEventHandlers() because ie9 implement CompositionEvent
when inInternationalComposition, NEW_CHANGES msg and ACCEPT_COMMIT msg
are pushed msgQueue.
when handleUserChanges(), apply msgQueue.