[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Sun, 20 Mar 2022 04:55:29 -0400 (EDT) |
branch: master
commit ca0de032c7aa25a6c1ee7bb0e980b1a6b2edc31b
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Tue Oct 20 14:05:41 2020 +0100
better quoting and recognize manual/html_node substring
---
js/infog/extension.c | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/js/infog/extension.c b/js/infog/extension.c
index ba62190a9c..6e628eccc7 100644
--- a/js/infog/extension.c
+++ b/js/infog/extension.c
@@ -143,6 +143,7 @@ request_callback (WebKitWebPage *web_page,
if (!manual || !node)
{
/* Possibly a *.css file or malformed link. */
+ debug (1, "COULDNT PARSE URL\n");
free (manual); free (node);
return FALSE;
}
@@ -462,23 +463,28 @@ send_pointer (WebKitDOMElement *link_elt,
free (link);
}
-/* Script to run in newly loaded files. End each line with a backslash.
- Avoid // or /* comments outside of strings. */
-#define INJECTED_JAVASCRIPTZ \
- var x = document.getElementsByClassName("texi-manual"); \
- for (var i = 0; i < x.length; i++) { \
- if (x[i].href) { \
- var re = new RegExp('^http://|^https://'); \
- x[i].href = x[i].href.replace(re, 'private:'); \
- } \
- }; \
- ;
+/* Use variadic macro to allow for commas in argument */
+#define QUOTE(...) #__VA_ARGS__
+
+const char *INJECTED_JAVASCRIPT = QUOTE(
+ var x = document.getElementsByClassName("texi-manual");
+ for (var i = 0; i < x.length; i++) {
+ var a = x[i].href;
+ var re = new RegExp('^http://|^https://');
+ if (a && a.match(re)) {
+ var array = a.match(/([^/]*)\\/manual\\/html_node\\/([^/]*)$/);
+ if (!Array.isArray(array) || array.length < 2) {
+ array = a.match(/([^/]*)\\/([^/]*)$/);
+ }
+ if (Array.isArray(array) && array.length >= 2) {
+ a = 'private:/' + array[1] + '/' + array[2];
+ x[i].href = a;
+ }
+ }
+ };
+);
-/* Use variadic macro to allow for commas in argument */
-#define stringize(...) #__VA_ARGS__
-#define dostringize(a) stringize(a)
-#define INJECTED_JAVASCRIPT dostringize(INJECTED_JAVASCRIPTZ)
void
- [no subject], (continued)
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject],
Gavin D. Smith <=
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20