Skip to content

Commit

Permalink
pad.html: fix regression introduced with 5879037.
Browse files Browse the repository at this point in the history
Revision 5879037 fixed a security bug, but introduced a regression, where
on page load the js console showed:

   ReferenceError: require is not defined

The reason was that the fix called require('../static/js/pad_utils') to load a
module at a time when require() was still not defined.
This change anticipates the loading of require-kernel, and manually loads
pad_utils.

The fix proposed in #3670 by aaron-costello, which seemed to do the right
thing, anticipating the configuration phase of require-kernel, did not work.
It had to be declined and replaced by this (less elegant) change.
  • Loading branch information
muxator committed Nov 30, 2019
1 parent ba38ed3 commit 695c2d2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/templates/pad.html
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,13 @@ <h2 data-l10n-id="pad.share.emebdcode"></h2>
<% e.end_block(); %>

<% e.begin_block("scripts"); %>
<script type="text/javascript">
var padutils = require('../static/js/pad_utils').padutils;

<script type="text/javascript" src="../static/js/require-kernel.js"></script>

<!-- Include pad_utils manually -->
<script type="text/javascript" src="../javascripts/lib/ep_etherpad-lite/static/js/pad_utils.js?callback=require.define"></script>

<script type="text/javascript">
// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt
(function() {
// Display errors on page load to the user
Expand All @@ -380,7 +384,6 @@ <h2 data-l10n-id="pad.share.emebdcode"></h2>
// @license-end
</script>

<script type="text/javascript" src="../static/js/require-kernel.js"></script>
<script type="text/javascript" src="../socket.io/socket.io.js"></script>

<!-- Include base packages manually (this help with debugging) -->
Expand Down

1 comment on commit 695c2d2

@aaron-costello
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me :)

Please sign in to comment.