-
Notifications
You must be signed in to change notification settings - Fork 160
Retire incoming Trackback support and normalize comment links #176
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
Open
snoopdave
wants to merge
3
commits into
entry-trackback-cleanup
Choose a base branch
from
incoming-trackback-retirement
base: entry-trackback-cleanup
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 14 additions & 49 deletions
63
...che/roller/weblogger/ui/rendering/plugins/comments/TrackbackLinkbackCommentValidator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,75 +1,40 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. The ASF licenses this file to You | ||
| * under the Apache License, Version 2.0 (the "License"); you may not | ||
| * use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. For additional information regarding | ||
| * copyright in this work, please see the NOTICE file in the top level | ||
| * directory of this distribution. | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.roller.weblogger.ui.rendering.plugins.comments; | ||
|
|
||
| import java.io.IOException; | ||
| import java.net.MalformedURLException; | ||
| import java.util.ResourceBundle; | ||
|
|
||
| import org.apache.roller.util.RollerConstants; | ||
| import org.apache.roller.weblogger.business.WebloggerFactory; | ||
| import org.apache.roller.weblogger.config.WebloggerRuntimeConfig; | ||
| import org.apache.roller.weblogger.pojos.WeblogEntryComment; | ||
| import org.apache.roller.weblogger.util.LinkbackExtractor; | ||
| import org.apache.roller.weblogger.util.RollerMessages; | ||
|
|
||
| /** | ||
| * Validates comment if comment's URL links back to the comment's entry, | ||
| * intended for use with trackbacks only. | ||
| * No-op retained temporarily for installations that still name this plugin. | ||
| * | ||
| * @deprecated The associated protocol endpoint is no longer available. | ||
| */ | ||
| @Deprecated(since = "6.1.6", forRemoval = true) | ||
| public class TrackbackLinkbackCommentValidator implements CommentValidator { | ||
|
|
||
| private ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources"); | ||
|
|
||
|
|
||
| @Override | ||
| public String getName() { | ||
| return bundle.getString("comment.validator.trackbackLinkbackName"); | ||
| return "Compatibility comment validator"; | ||
| } | ||
|
|
||
| @Override | ||
| public int validate(WeblogEntryComment comment, RollerMessages messages) { | ||
|
|
||
| // linkback validation can be toggled at runtime, so check if it's enabled | ||
| // if it's disabled then just return a score of 100 | ||
| if(!WebloggerRuntimeConfig.getBooleanProperty("site.trackbackVerification.enabled")) { | ||
| return RollerConstants.PERCENT_100; | ||
| } | ||
|
|
||
| int ret = 0; | ||
| LinkbackExtractor linkback = null; | ||
| try { | ||
| linkback = new LinkbackExtractor( | ||
| comment.getUrl(), | ||
| WebloggerFactory.getWeblogger().getUrlStrategy().getWeblogEntryURL( | ||
| comment.getWeblogEntry().getWebsite(), | ||
| null, | ||
| comment.getWeblogEntry().getAnchor(), | ||
| true)); | ||
| } catch (MalformedURLException ignored1) { | ||
| } catch (IOException ignored2) {} | ||
|
|
||
| if (linkback != null && linkback.getExcerpt() != null) { | ||
| ret = RollerConstants.PERCENT_100; | ||
| } else { | ||
| messages.addError("comment.validator.trackbackLinkbackMessage"); | ||
| } | ||
| return ret; | ||
| return RollerConstants.PERCENT_100; | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this runs the validator (regex +
DomainValidatorlookup) on every call, andComments.jspevaluates#comment.safeUrlthree times per row whileweblog.vmevaluates$comment.urltwice per comment. Compute once per render (ans:setin the JSP, a local in the macro, or memoize in the wrapper).