cosmocode / edittable

Plugin to provide a custom editor for tables in DokuWiki
https://www.dokuwiki.org/plugin:edittable
32 stars 26 forks source link

it is possible to make this plugin compatible with the plugin encryptedpasswords #194

Open VDI93 opened 4 years ago

VDI93 commented 4 years ago

Hello, it is possible to make this plugin compatible with the plugin encryptedpasswords? https://www.dokuwiki.org/plugin:encryptedpasswords

The plugin edittable provide a nice interface for editing table but the button encrypt doesn't respond in combination with edittable und encryptedpasswords

many thanks!

kalenpw commented 3 years ago

Following, I've been workin on this today (and affected by it for a while).

The primary problem I run into is when you store an encrypted password in a table and then edit said table, it strips the <decrypt> tags from around it thus breaking it for future usage.

At first I was trying to just put together a kludge that didn't strip away <decrypt>, but didn't have much luck.

I'm wondering if we'd be better off creating a new handler function in Doku_Handler and adding a pattern for <decrypt>

Something vageuly like this (based off https://www.dokuwiki.org/devel:parser):

// inc/parser/parser.php
$Lexer->addEntryPattern('<decrypt>', 'edit', 'decrypt');
$Lexer->addExitPattern('</decrypt>','decrypt');

// inc/parser/handler.php
function decrypt($match, $state, $pos) {
    return true; // do we need to do additional processing here?
}

Hopefully @splitbrain can give some pointers

kalenpw commented 3 years ago

I've got a working solution, I'm not sure if it is the cleanest or not but here is what you can do.

Edit lib/plugins/edittable/renderer/inverse.php

Roughly line 633 is the plugin function. You need to tweak that to check if it's the encryptedpasswords plugin and if so add the decrypt tags

Here is my complete function

    function plugin($name, $args, $state = '', $match = '') {
        if($name === "encryptedpasswords") {
            $this->doc .= "<decrypt>$match</decrypt>";
        }
        else {
            $this->doc .= $match;
        }
        // This will break for plugins which provide a catch-all render method
        // like the do or pagenavi plugins
#        $plugin =& plugin_load('syntax',$name);
#        if($plugin === null || !$plugin->render($this->getFormat(),$this,$args)) {
#        }
    }
Floffyko commented 3 years ago

Hm... 3 Month ago I was forced to downgrade th encryptedpasswords to 2013-03-13 version in order to be compatible with Editable. So, kalenpw, my another idea is to compare the current encryptedpasswords version with 2013 one in order to find out what changes are there that make it incompatible.

Like I already said, the current Editable work without problems with encryptedpasswords version 2013.

ssahara commented 3 years ago

@Floffyko, Thank you for sharing your idea. I hope the updated encryptedpasswords plugin 2020-11-02 will solve this issue.