ssb: Handful of URL encoding issues.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"type": "tildefriends-app",
|
"type": "tildefriends-app",
|
||||||
"emoji": "🦀",
|
"emoji": "🦀",
|
||||||
"previous": "&+/LuVOJUXuNSQRUD8PSgGzOdsWx47TPDcyUef5An2JQ=.sha256"
|
"previous": "&KPnjURiuJa5b0ONjxz11bMm7yuhY9wlBTyB+fzl0zzk=.sha256"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -707,9 +707,7 @@ class TfElement extends LitElement {
|
|||||||
.following=${this.following}
|
.following=${this.following}
|
||||||
whoami=${this.whoami}
|
whoami=${this.whoami}
|
||||||
.users=${this.users}
|
.users=${this.users}
|
||||||
query=${this.hash?.startsWith('#q=')
|
query=${this.search_text()}
|
||||||
? decodeURIComponent(this.hash.substring(3))
|
|
||||||
: null}
|
|
||||||
></tf-tab-search>
|
></tf-tab-search>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -758,7 +756,7 @@ class TfElement extends LitElement {
|
|||||||
search_text.focus();
|
search_text.focus();
|
||||||
this.set_tab('search');
|
this.set_tab('search');
|
||||||
} else {
|
} else {
|
||||||
this.set_hash('#q=' + search_text.value);
|
this.set_hash('#q=' + encodeURIComponent(search_text.value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -768,6 +766,16 @@ class TfElement extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
search_text() {
|
||||||
|
if (this.hash.startsWith('#q=')) {
|
||||||
|
try {
|
||||||
|
return decodeURIComponent(this.hash.substring('#q='.length));
|
||||||
|
} catch {
|
||||||
|
return this.hash.substring('#q='.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
@@ -832,7 +840,7 @@ class TfElement extends LitElement {
|
|||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
<button class="w3-bar-item w3-button w3-right" @click=${this.search}>🔍<span class="w3-hide-small">Search</span></button>
|
<button class="w3-bar-item w3-button w3-right" @click=${this.search}>🔍<span class="w3-hide-small">Search</span></button>
|
||||||
<input type="text" class=${'w3-input w3-bar-item w3-right w3-theme-d1' + (this.tab == 'search' ? ' w3-mobile' : ' w3-hide-small')} placeholder="keywords, @id, #channel" id="search_text" @keydown=${this.search_keydown}></input>
|
<input type="text" class=${'w3-input w3-bar-item w3-right w3-theme-d1' + (this.tab == 'search' ? ' w3-mobile' : ' w3-hide-small')} placeholder="keywords, @id, #channel" id="search_text" @keydown=${this.search_keydown} value=${this.search_text()}></input>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
let contents = this.guest
|
let contents = this.guest
|
||||||
|
|||||||
@@ -44,36 +44,37 @@ class TfTabSearchElement extends LitElement {
|
|||||||
this.error = undefined;
|
this.error = undefined;
|
||||||
this.results = [];
|
this.results = [];
|
||||||
this.messages = [];
|
this.messages = [];
|
||||||
if (query.startsWith('sql:')) {
|
try {
|
||||||
this.messages = [];
|
if (query.startsWith('sql:')) {
|
||||||
try {
|
this.messages = [];
|
||||||
this.results = await tfrpc.rpc.query(
|
this.results = await tfrpc.rpc.query(
|
||||||
query.substring('sql:'.length),
|
query.substring('sql:'.length),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} else {
|
||||||
this.results = [];
|
let results = await tfrpc.rpc.query(
|
||||||
this.error = e;
|
`
|
||||||
|
SELECT messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
||||||
|
FROM messages_fts(?)
|
||||||
|
JOIN messages ON messages.rowid = messages_fts.rowid
|
||||||
|
JOIN json_each(?) AS following ON messages.author = following.value
|
||||||
|
ORDER BY timestamp DESC limit 100
|
||||||
|
`,
|
||||||
|
['"' + query.replace('"', '""') + '"', JSON.stringify(this.following)]
|
||||||
|
);
|
||||||
|
search = this.renderRoot.getElementById('search');
|
||||||
|
if (search) {
|
||||||
|
search.value = query;
|
||||||
|
search.focus();
|
||||||
|
search.select();
|
||||||
|
}
|
||||||
|
this.messages = results;
|
||||||
}
|
}
|
||||||
} else {
|
} catch (e) {
|
||||||
let results = await tfrpc.rpc.query(
|
this.messages = [];
|
||||||
`
|
this.results = [];
|
||||||
SELECT messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
this.error = e;
|
||||||
FROM messages_fts(?)
|
console.log(e);
|
||||||
JOIN messages ON messages.rowid = messages_fts.rowid
|
|
||||||
JOIN json_each(?) AS following ON messages.author = following.value
|
|
||||||
ORDER BY timestamp DESC limit 100
|
|
||||||
`,
|
|
||||||
['"' + query.replace('"', '""') + '"', JSON.stringify(this.following)]
|
|
||||||
);
|
|
||||||
console.log('Done.');
|
|
||||||
search = this.renderRoot.getElementById('search');
|
|
||||||
if (search) {
|
|
||||||
search.value = query;
|
|
||||||
search.focus();
|
|
||||||
search.select();
|
|
||||||
}
|
|
||||||
this.messages = results;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,9 @@ class TfUserElement extends LitElement {
|
|||||||
name = this.icon_only
|
name = this.icon_only
|
||||||
? undefined
|
? undefined
|
||||||
: !this.nolink
|
: !this.nolink
|
||||||
? html`<a target="_top" href=${'#' + this.id}>${name_string}</a>`
|
? html`<a target="_top" href=${'#' + encodeURIComponent(this.id)}
|
||||||
|
>${name_string}</a
|
||||||
|
>`
|
||||||
: html`<span>${name_string}</span>`;
|
: html`<span>${name_string}</span>`;
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
|
|||||||
Reference in New Issue
Block a user