• Hey guys,

    First off I want to say Search Everything is a great plugin. Thanks for
    your work on it.

    We did discover a couple issues though. (I’ll open a separate thread for the other one as it’s a different issue altogether.)

    On the plugin settings page, if you enter a CSS color in the “Highlight Background Color” option, and use all caps (like your example), you get this error message:

    Oops, there are errors in your submit:

    • field Highlight Background Color should be a css color (‘red’ or ‘#abc123’)

    Please go back and check your settings again.

    Ironically, if you type in the CSS color used in the example below the input box…”#FFF984″, it will not work, and you get the error message.

    It looks like you’re forcing all entries to be lowercase or they won’t validate. That is not the best way to validate CSS…you should be using case insensitive matching or lowercase the CSS input value in PHP before you test it.

    We put together a fix, and it’s not many lines of code that need to change.

    In options.php line 110, you have:

    if(!preg_match("/$rule/", $_POST[$field])) {

    which uses case-sensitive matching. You don’t want case-sensitive matching, so that needs to include the i modifier. It should be:

    if(!preg_match("/$rule/i", $_POST[$field])) {

    In options.php on line 98 you have this:

    "color" => "^(([a-z]+)|(#[0-9a-f]{2,6}))$",

    which should be changed to this:

    "color" => "^(([a-fA-F]+)|(#[0-9a-fA-F]{2,6}))$",

    The regex rules do need further fixing though, as they don’t accommodate for valid 3 digit hex color values like #FFF. To fix that you would need something like this:

    "color" => "^(([a-fA-F]+)|#([0-9a-fA-F]{3}){1,2})$",

    Even so, the regex rules still need further fixing, because they don’t properly validate the 140 named colors – it currently allows random lowercase words that are not valid colors. To do that, you will need to add the following line after line 96:

    $named_colors = array('aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'beige', 'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet', 'brown', 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral', 'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkkhaki', 'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', 'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray', 'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'fuchsia', 'gainsboro', 'ghostwhite', 'gold', 'goldenrod', 'gray', 'green', 'greenyellow', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory', 'khaki', 'lavender', 'lavenderblush', 'lawngreen', 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightslategray', 'lightsteelblue', 'lightyellow', 'lime', 'limegreen', 'linen', 'magenta', 'maroon', 'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'moccasin', 'navajowhite', 'navy', 'oldlace', 'olive', 'olivedrab', 'orange', 'orangered', 'orchid', 'palegoldenrod', 'palegreen', 'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'purple', 'red', 'rosybrown', 'royalblue', 'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna', 'silver', 'skyblue', 'slateblue', 'slategray', 'snow', 'springgreen', 'steelblue', 'tan', 'teal', 'thistle', 'tomato', 'turquoise', 'violet', 'wheat', 'white', 'whitesmoke', 'yellow', 'yellowgreen');

    Then replace line 98 (now line 99) with this:

    "color" => "^(#([0-9a-f]{3}){1,2}|".implode('|',$named_colors).")$",

    We tested and implemented this, and it works well.

    Please fix this as soon as possible. Thank you.

    – Scott

    https://wordpress.org/plugins/search-everything/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter redsand

    (@redsand)

    For anyone else reading, if you want to fix this yourself until the plugin is updated, here’s the TL;DR version of the fix above.

    Open up the file search-everything/options.php.

    Change line 110 from this:

    if(!preg_match("/$rule/", $_POST[$field])) {

    to this:

    if(!preg_match("/$rule/i", $_POST[$field])) {

    Change line 98 from this:

    "color" => "^(([a-z]+)|(#[0-9a-f]{2,6}))$",

    to this:

    "color" => "^(#([0-9a-f]{3}){1,2}|".implode('|',$named_colors).")$",

    Last, add a line after line 96, that has this:

    $named_colors = array('aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'beige', 'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet', 'brown', 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral', 'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkkhaki', 'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', 'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray', 'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'fuchsia', 'gainsboro', 'ghostwhite', 'gold', 'goldenrod', 'gray', 'green', 'greenyellow', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory', 'khaki', 'lavender', 'lavenderblush', 'lawngreen', 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightslategray', 'lightsteelblue', 'lightyellow', 'lime', 'limegreen', 'linen', 'magenta', 'maroon', 'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'moccasin', 'navajowhite', 'navy', 'oldlace', 'olive', 'olivedrab', 'orange', 'orangered', 'orchid', 'palegoldenrod', 'palegreen', 'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'purple', 'red', 'rosybrown', 'royalblue', 'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna', 'silver', 'skyblue', 'slateblue', 'slategray', 'snow', 'springgreen', 'steelblue', 'tan', 'teal', 'thistle', 'tomato', 'turquoise', 'violet', 'wheat', 'white', 'whitesmoke', 'yellow', 'yellowgreen');

    DONE! It will properly validate all CSS colors, and won’t allow invalid entries.

    (I listed the steps backwards on purpose, to avoid confusion from the changing line numbers.)

    Thread Starter redsand

    (@redsand)

    Apologies…I left out a ?…line 98 should be:

    "color" => "^(#([0-9a-f]{3}){1,2}|".implode('|',$named_colors).")?$",

    Thanks a lot!

    Thread Starter redsand

    (@redsand)

    @samariter: You’re welcome! 🙂

    I agree with you – this is a time waster as the error message doesn’t give an accurate reason for the error. Even if the error message was updated to show that case is the issue that would help a lot.

    Great plugin though!

    Thread Starter redsand

    (@redsand)

    STILL not fixed…

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Error Saving CSS Colors on Settings Page’ is closed to new replies.