Skip to content

Commit

Permalink
Merge pull request #23 from deltachat/r10s/fix-bad-input
Browse files Browse the repository at this point in the history
fix badly encoded %23
  • Loading branch information
r10s authored Jan 28, 2024
2 parents 95e42fd + 1386510 commit a6365a5
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
<li>
<span class="step-paste"></span>
<br>
<textarea autofocus oninput="reactInput(this.value)"></textarea>
<textarea autofocus oninput="textareaInput(this.value)"></textarea>
</li>
<li>
<span class="step-share"></span>
Expand Down Expand Up @@ -257,6 +257,25 @@
(isValid ? document.querySelector('form') : document.querySelector('section')).classList.add('hidden');
};

// when all apps can generate invite links internally, we may decide to remove on-site generator
// and instead show a page with instructions how to generate links in Delta Chat
function textareaInput(inputData) {
// be idempotent: allow pasting a already generated invite-link to the generator (esp. if generated by the app)
if (inputData.startsWith('https://i.delta.chat')) {
inputData = inputData.replace(/https:\/\/i.delta.chat\/?#/, '')
inputData = inputData.replace(/&/, '#')
} else {
inputData = inputData.replace(/openpgp4fpr:/i, '')
}

// '#' may be wrongly encoded to '%23' by Safari/iOS; convert it back. see issue #16
if (inputData.indexOf('#') == -1) {
inputData = inputData.replace(/%23/, '#')
}

reactInput(inputData)
}

reactInput(window.location.hash.substr(1));

i18next.init({
Expand Down

0 comments on commit a6365a5

Please sign in to comment.