Giter VIP home page Giter VIP logo

safe-report-comments's Issues

See if there are better options than comment_reply_link

Either a different hook (back compat risk), or better regex.

I note primarily because Twenty Twenty runs some code there that makes our regex not match. But it's unclear to the user that there's an issue and just looks broken.

Possible issue with unserializing Cookie data

I discovered this while working on #13. I believe I confirmed it's not a regression, but would welcome confirmation.

Issue

When re-flagging a comment, I do not get the expected "already flagged" message.

Reproduce

  1. Activate the plugin on a site running any default theme but Twenty Twenty (#14).
  2. Add an approve at least one comment for testing on.
  3. View the comment on the front-end and click "Report Comment"
  4. Note you'll get a sfrc_flags cookie value something like this eyIxOTAzMCI6MX0%3D

The problem is during unserialization

private function unserialize_cookie( $value ) {
$data = json_decode( base64_decode( $value ) );
return $this->clean_cookie_data( $data );
}

Problem one is the base64 decoding leaves a trailing character

wp> $base64 = base64_decode( 'eyIxOTAzMCI6MX0%3D' )
=> string(12) "{"19030":1}7"

Which then prevents json decoding

wp> json_decode( $base64 );
=> NULL

Because the data ends up as null (which is "cleaned" into an empty array), our comment isn't found in the data so is not considered "already flagged".

Note: It may be difficult to fully see this on the front-end due to the transients fallback. Conditional blocks at

if ( $transient = get_transient( md5( $this->_storagecookie . $remote_addr ) ) ) {
and
if ( !$transient ) {
can be commented out for testing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.