Changeset 594cc50 in Klonkt


Ignore:
Timestamp:
06/24/2026 12:47:56 PM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
2826bb97
Parents:
3d7312a
Message:

fix(activitypub): remote-reply button — data attrs + delegated handler

The inline onclick used JSON.stringify (double quotes) inside a double-quoted
attribute, which closed the attribute early and broke the button. Replaced with
data-* attributes + a single delegated click handler.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/views/pages/post.ejs

    r3d7312a r594cc50  
    139139  <% var _postAbsUrl = (typeof ogOrigin !== 'undefined' && ogOrigin ? ogOrigin : '') + (typeof _base !== 'undefined' && _base ? _base : '') + '/' + post.slug; %>
    140140  <div class="post-fediverse-cta">
    141     <button type="button" class="btn fedi-remote-reply-btn"
    142       onclick="(function(){var d=prompt(<%- JSON.stringify(t('fedi.remote_prompt')) %>);if(!d)return;d=d.trim().replace(/^@?[^@\s]*@/,'').replace(/^https?:\/\//i,'').replace(/\/.*$/,'').trim();if(d)location.href='https://'+d+'/authorize_interaction?uri='+encodeURIComponent(<%- JSON.stringify(_postAbsUrl) %>);})()">
    143       🐘 <%= t('fedi.remote_reply') %>
    144     </button>
     141    <button type="button" class="btn fedi-remote-reply-btn" data-fedi-uri="<%= _postAbsUrl %>" data-fedi-prompt="<%= t('fedi.remote_prompt') %>">🐘 <%= t('fedi.remote_reply') %></button>
    145142  </div>
     143  <script>
     144  (function(){
     145    if (window.__fediRemoteWired) return; window.__fediRemoteWired = true;
     146    document.addEventListener('click', function(e){
     147      var b = e.target.closest && e.target.closest('.fedi-remote-reply-btn');
     148      if (!b) return;
     149      var d = prompt(b.getAttribute('data-fedi-prompt') || ''); if (!d) return;
     150      d = d.trim().replace(/^@?[^@\s]*@/, '').replace(/^https?:\/\//i, '').replace(/\/.*$/, '').trim();
     151      if (d) location.href = 'https://' + d + '/authorize_interaction?uri=' + encodeURIComponent(b.getAttribute('data-fedi-uri') || '');
     152    });
     153  })();
     154  </script>
    146155
    147156  <!-- Comments -->
Note: See TracChangeset for help on using the changeset viewer.