Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent redundant entries from being added to Adlists.list #1954

Merged
merged 4 commits into from May 31, 2018

Conversation

ryanknapper
Copy link
Contributor

@ryanknapper ryanknapper commented Feb 7, 2018

By submitting this pull request, I confirm the following: {please fill any appropriate checkboxes, e.g: [X]}

{Please ensure that your pull request is for the 'development' branch!}

  • I have read and understood the contributors guide, as well as this entire template.
  • I have made only one major change in my proposed changes.
  • [] I have commented my proposed changes within the code.
  • I have tested my proposed changes, and have included unit tests where possible.
  • I am willing to help maintain this change if there are issues with it later.
  • I give this submission freely and claim no ownership.
  • It is compatible with the EUPL 1.2 license
  • I have squashed any insignificant commits. (git rebase)
  • I have Signed Off all commits. (git commit --signoff)

What does this PR aim to accomplish?:

Presently a user can add redundant entries to adlists.list, each of which Gravity will check for updates.

How does this PR accomplish the above?:

A simple grep for the proposed change. If true, do nothing.

What documentation changes (if any) are needed to support this PR?:

None needed.

Updated webpage.sh to include conditional forwarding options.
Grep ${args[3]} and only add if grep -c -eq 0

Signed-off-by: Ryan Knapper <ryanknapper@gmail.com>
Reduced differences.

Signed-off-by: Ryan Knapper <ryanknapper@gmail.com>
jacobsalmela
jacobsalmela previously approved these changes Feb 18, 2018
Copy link
Contributor

@jacobsalmela jacobsalmela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This indeed fixes this behavior.

@jacobsalmela jacobsalmela added this to the v3.3.1 milestone Feb 18, 2018
@jacobsalmela jacobsalmela added this to To do in Release v3.3.1 via automation Feb 18, 2018
@jacobsalmela jacobsalmela added the Bug: fixed Contains a bug resolution label Feb 18, 2018
AzureMarker
AzureMarker previously approved these changes Feb 18, 2018
@DL6ER
Copy link
Member

DL6ER commented Feb 18, 2018

Does this look for exact matches? I don't think so. The likeliness of the following might be small, but assume I have a list

http://blocking-list-provider.com/tracker

Assume now, they also offer a list like

http://blocking-list-provider.com/tracker-german

I think with your proposed solution, the latter one cannot be added if the former is already present. I might be mistaken here (I'm not in the position to test this right now), but it is something I would like to be through about.

@jacobsalmela
Copy link
Contributor

I didn't think of this, but it still appears to work with in the situation you described.
screenshot 2018-02-18 16 08 17

@dschaper dschaper added PR: Code Review Required Open Pull Request, needs code reviewd PR: Approval Required Open Pull Request, needs approval labels Feb 23, 2018
@@ -346,7 +346,9 @@ CustomizeAdLists() {
elif [[ "${args[2]}" == "disable" ]]; then
sed -i "\\@${args[3]}@s/^http/#http/g" "${list}"
elif [[ "${args[2]}" == "add" ]]; then
echo "${args[3]}" >> ${list}
if [[ $(grep -c "${args[3]}" "${list}") -eq 0 ]] ; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably be doing an exact comparison here to avoid the situation I described above from happening. Just use the proper anchors here:

grep -c "^${args[3]}$" "${list}"

Updated to require an exact match to reduce false-positives, as suggested by DL6ER.

Signed-off-by: Ryan Knapper <ryanknapper@gmail.com>
@ryanknapper
Copy link
Contributor Author

Suggested corrections made.

@AzureMarker
Copy link
Contributor

AzureMarker commented May 31, 2018

Do we want to finish this PR? If so, @DL6ER, please re-review.

@AzureMarker AzureMarker merged commit ab45360 into pi-hole:development May 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: fixed Contains a bug resolution PR: Approval Required Open Pull Request, needs approval PR: Code Review Required Open Pull Request, needs code reviewd
Projects
No open projects
Release v3.3.1
  
To do
Development

Successfully merging this pull request may close these issues.

None yet

5 participants