OSDN Git Service

BugTrack/2547 color plugin and COLOR format: hex and name color
authorumorigu <umorigu@gmail.com>
Mon, 10 Jan 2022 23:44:45 +0000 (08:44 +0900)
committerumorigu <umorigu@gmail.com>
Mon, 10 Jan 2022 23:44:45 +0000 (08:44 +0900)
* name color max length is 20
* hex color starts with '#'; its hex part length is in [3,6]

default.ini.php
keitai.ini.php
lib/convert_html.php
plugin/color.inc.php

index 61bbc8e..d36733a 100644 (file)
@@ -111,9 +111,11 @@ $usefacemark = 1;
 /////////////////////////////////////////////////
 // ユーザ定義ルール(コンバート時に置換)
 $line_rules = array(
-       'COLOR\(([^\(\)]*)\){([^}]*)}'  => '<span style="color:$1">$2</span>',
+       'COLOR\(((?:[a-zA-Z]{1,20})|(?:#[0-9a-fA-F]{3,6}))\){([^}]*)}'
+               => '<span style="color:$1">$2</span>',
        'SIZE\((\d{1,2})\){([^}]*)}' => '<span style="font-size:$1px">$2</span>',
-       'COLOR\(([^\(\)]*)\):((?:(?!COLOR\([^\)]+\)\:).)*)'     => '<span style="color:$1">$2</span>',
+       'COLOR\(((?:[a-zA-Z]{1,20})|(?:#[0-9a-fA-F]{3,6}))\):((?:(?!COLOR\([^\)]+\)\:).)*)'
+               => '<span style="color:$1">$2</span>',
        // "SIZE(n):" PukiWiki 1.3 compatible notation
        'SIZE\(([1-7])\):((?:(?!SIZE\([^\)]+\)\:).)*)' => '<span class="size$1">$2</span>',
        '%%%(?!%)((?:(?!%%%).)*)%%%'    => '<ins>$1</ins>',
index 49f0276..0ec6e2e 100644 (file)
@@ -178,9 +178,11 @@ switch ("$ua_name/$ua_vers") {
 
 // ユーザ定義ルール(コンバート時に置換)
 $line_rules = array(
-       'COLOR\(([^\(\)]*)\){([^}]*)}'  => '<font color="$1">$2</font>',
+       'COLOR\(((?:[a-zA-Z]{1,20})|(?:#[0-9a-fA-F]{3,6}))\){([^}]*)}'
+               => '<font color="$1">$2</font>',
        'SIZE\((\d{1,2})\){([^}]*)}' => '$2', // Disabled
-       'COLOR\(([^\(\)]*)\):((?:(?!COLOR\([^\)]+\)\:).)*)'     => '<font color="$1">$2</font>',
+       'COLOR\(((?:[a-zA-Z]{1,20})|(?:#[0-9a-fA-F]{3,6}))\):((?:(?!COLOR\([^\)]+\)\:).)*)'
+               => '<font color="$1">$2</font>',
        // "SIZE(n):" PukiWiki 1.3 compatible notation
        'SIZE\(([1-7])\):((?:(?!SIZE\([^\)]+\)\:).)*)' => '$2', // Disabled
        '%%%(?!%)((?:(?!%%%).)*)%%%'    => '<ins>$1</ins>',
index 87f80c6..2dba3c1 100644 (file)
@@ -522,7 +522,7 @@ class TableCell extends Element
                parent::__construct();
                $this->style = $matches = array();
 
-               while (preg_match('/^(?:(LEFT|CENTER|RIGHT)|(BG)?COLOR\(([#\w]+)\)|SIZE\((\d{1,2})\)|(BOLD)):(.*)$/',
+               while (preg_match('/^(?:(LEFT|CENTER|RIGHT)|(BG)?COLOR\((#?\w{1,20})\)|SIZE\((\d{1,2})\)|(BOLD)):(.*)$/',
                    $text, $matches)) {
                        if ($matches[1]) {
                                $this->style['align'] = 'text-align:' . strtolower($matches[1]) . ';';
index 4199afa..171bb37 100644 (file)
@@ -2,7 +2,7 @@
 // PukiWiki - Yet another WikiWikiWeb clone.
 // color.inc.php
 // Copyright
-//   2003-2016 PukiWiki Development Team
+//   2003-2022 PukiWiki Development Team
 // License: GPL v2 or (at your option) any later version
 //
 // Text color plugin
@@ -13,7 +13,7 @@ define('PLUGIN_COLOR_ALLOW_CSS', TRUE); // TRUE, FALSE
 
 // ----
 define('PLUGIN_COLOR_USAGE', '&color(foreground[,background]){text};');
-define('PLUGIN_COLOR_REGEX', '/^(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z-]+)$/i');
+define('PLUGIN_COLOR_REGEX', '/^(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z-]{1,20})$/i');
 
 function plugin_color_inline()
 {