-
Notifications
You must be signed in to change notification settings - Fork 309
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
Add support for only one last @supportURL
, fix naming standardization, and such
#189
Add support for only one last @supportURL
, fix naming standardization, and such
#189
Conversation
…ation **NOTE**: It appears that Zren is using `.meta` to be the actual metadata block items and so any manipulation of these should be stored elsewhere just in case `collaborators`, etc. is ever used/supported in a metadata block... doubt it will based off of Anthony's prior responses but does make the code simpler to read. Applies to: * OpenUserJS#174 * OpenUserJS#161
Applies to OpenUserJS#189
@@ -35,11 +35,12 @@ | |||
</ul> | |||
</span> | |||
{{/script.hasGroups}} | |||
{{#script.meta.homepages}}<p><i class="fa fa-fw fa-home"></i> <b>Homepage:</b> <a href="{{name}}">{{name}}</a></p>{{/script.meta.homepages}} | |||
{{#script.homepages}}<p><i class="fa fa-fw fa-home"></i> <b>Homepage:</b> <a href="{{name}}">{{name}}</a></p>{{/script.homepages}} | |||
{{#script.support}}<p><i class="fa fa-fw fa-support"></i> <b>Support:</b> <a href="{{script.support}}">{{script.support}}</a></p>{{/script.support}} |
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.
@supportURL javascript:alert(document.cookie);
Although mailto:
might be a nice protocol to keep.
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.
We'll need to add a validation filter to all linkified ones then... not just @supportURL
. I'll be away for this weekend btw. So a new issue towards Munday?
…onent` Output HTML on dev: * `<a href="/users/%3Ci%3Edoes%20this%20italicize%3C%2Fi%3E"><i>does this italicize</i></a>` ... instead of HTML entity escaping
Applies to OpenUserJS#189 * Add sanitize-html for `@supportURL` and `@homepageURL` parts * Sanitize those urls using a html stub encasement... only push if exactly equal. e.g. don't show if they aren't * Create html whitelist link json for this since it's used multiple times * Change affected view page to accomodate changes Tested on dev okay but needs testing verification
@sizzlemctwizzle @OpenUserJs/admin @OpenUserJs/backend (interesting that I can't do this list) @OpenUserJs/frontend (interesting that I can't do this list) Everyone please remember to read my commit messages... they tell everyone what a commit is doing in plain english along with sensible variable names. TIA Are there any other use cases anyone can think of to hack these values? Tested on dev at this new script ... somehow I've lost access to the original script on both pro and dev. :\ Btw do we want a simple Another thing... I know V8 doesn't do block level disposable variables but should we be coding as if it may eventually? The difference is: ES5ish var tempIdentifier;
if (true) {
tempIdentifier = 1;
// Do something with tempIdentifier but not used anywhere else outside of this block
} else {
tempIdentifier = 2;
// Do something with tempIdentifier but not used anywhere else outside of this block
} vs. future support of ES6 (Harmony) if (true) {
var tempIdentifier = 1;
// Do something with tempIdentifier but not used anywhere else outside of this block
} else {
var tempIdentifier = 2;
// Do something with tempIdentifier but not used anywhere else outside of this block
} ... obviously in ES6 it would be a Since the full test script is currently local here.. here is the last known metadata block: // ==UserScript==
// @name RFC 2606§3 - @license and @licence (recovered) Unit Test
// @namespace http://localhost.localdomain
// @description Tests out non-unique keys
// @copyright 2007+, Marti Martz (http://userscripts.org/users/37004)
// @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
// @licence (CC); http://creativecommons.org/licenses/by-nc-sa/3.0/
// @version 2014.06.22.0
// @icon https://s3.amazonaws.com/uso_ss/icon/13701/large.png
// @homepage http://localhost:8080/scripts/Marti/RFC_2606%C2%A73_-_license_and_licence_%28recovered%29_Unit_Test
// @homepage https://openuserjs.org/scripts/Marti/RFC_2606%C2%A73_-_license_and_licence_%28recovered%29_Unit_Test
// @homepage javascript:alert('hello, world');
// @homepageURL mailto:user@example.com
// @supportURL http://localhost:8080/scripts/Marti/RFC_2606%C2%A73_-_license_and_licence_(recovered)_Unit_Test/issues
// @supportURL javascript:alert('hello, world');
// @supportURL mailto:user@example.com
// @include http://www.example.com/*
// @include http://www.example.net/*
// @include http://www.example.org/*
// @author Marti
// @collaborator sizzle
// @collaborator Zren
// @collaborator This User Better Not Exist
// @collaborator <i>does this italicize or generate invalid encoded href</i>
// ==/UserScript== |
@supportURL
and fix naming standardization@supportURL
, fix naming standardization, and such
if (script.meta.supportURL) { | ||
if (_.isString(script.meta.supportURL)) { | ||
var htmlStub = '<a href="' + script.meta.supportURL + '"></a>'; | ||
if (htmlStub === sanitizeHtml(htmlStub, htmlWhitelistLink)) { |
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.
Can you tell why you do this?
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.
Can you tell why you do this?
See #189 (comment)
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.
I was wondering more about technical why.
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.
Only thing I could think of is if an inexperienced user would accidentally click on this type of link with a script and add an event listener to monitor keystrokes... Sanitizing it keeps it from doing this. Also sizzle mentioned the stealing cookie bit... so a cross-domain call or even within the same domain posting somewhere could be achieved. The html tag sanitization can be used in case anyone accidentally uses {{{text}}}
and commits a bug with a potential security issue. So basically a two fold potential op here. If you have any other recommendations we don't have to use this. I am just fixing and cleaning up the bug introduced from the new UI in #103 and #129. Reusing existing objects (methods) already in memory will help the drones too. As I've mentioned before I'm not blaming because we all make mistakes and I propagated this one... and then sizzle caught it. I'm quite thankful for all the verification/testing provided. :)
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.
Sorry, dyslectic person here. I meant what happens on this specific line? sanitizeHtml
validates if htmlStub
is valid html and you compare it to the original? What happens if the url contains a trailing space?
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.
What happens if the url contains a trailing space?
It won't because the imported CI/iW/usoC routine should be trimming and we are using/storing a copy of the metadata block.
Fast review
Yes. Outside urls should have
-1 for me. Keep things simple and one standard. |
For all outside links, yes, unless we whitelist certain domains (MDN, github, etc.).
I am also a -1 based on the massive amount of red on the kangax table. |
Thanks guys. Okay give me a few moments and I'll move the |
…in node.js and downgrade to ES5 standards, and [our current styleguide enforcement](OpenUserJS@0263c79#diff-ba2dc84c4bcbe54f368b6c7d3bc1b13eR39) Applies to OpenUserJS#189
* One other bug fix for single `@supportURL` usage... copy/paste goof Applies to OpenUserJS#189
Updated dev test script
I recommend that we save this part for another issue upon user request. This gets more into SEO than I think we are ready for just yet (don't see any robots.txt either in our source)... plus we might be perceived as "taking sides" if there is ever a conflict between one user request and another. A discussion best suited for another issue I think. :) Fixed both of those concerned issues... anything else? |
…d set to `null` * See [here](OpenUserJS@0263c79#diff-ba2dc84c4bcbe54f368b6c7d3bc1b13eR28) Applies to OpenUserJS#189
Shouldn't we show |
If isn't a valid url, why should we list it as a support url?
|
Showing invalid ones will involve more mustache logic. I opted out because it's just as easy to check the source for invalid entries... but what we do show with linking we should validate as much as possible... A variant of Count Issues (CI) will probably be rewritten eventually for OUJS for those looking for extreme specifics. (this is going to be interesting trying to do this on the homepage because it will probably trigger a script counter update :\ I will probably need to do this on Source Code page instead.) ... plus there is oujs - Meta View right now. This is nearing the bare minimum I think that we should show unless someone requests something else that we all agree upon. |
That's fine.
I agree. Did found some useful ones at Scriptish... (Edit: reference issue #197 ) |
I did some fast reviewing of this PR and I'm +1 on merging. Edit: |
Regular expressions (re) aren't always the answer for everything... sometimes more human readable methodologies in our base language of JavaScript are preferred instead of a syntax of its own using re. Which re is implemented is another factor... each programming language and even ES implementation sometimes have different rules.
There is no way to guarantee someone is going to use the |
Add support for only one last `@supportURL`, fix naming standardization, and such
* Missed one in OpenUserJS#189 and applies to OpenUserJS#161
* Trap if a Userscript doesn't encode one of these urls correctly. Fixes "Page Load Error" with "Failed to Connect"... server trip Applies to OpenUserJS#819, OpenUserJS#239, OpenUserJS#197, and OpenUserJS#189 Ref: * https://openuserjs.org/discuss/webhook_not_working
NOTE: It appears that Zren is using
.meta
to be the actual metadata block item names and so any manipulation of these should be stored elsewhere just in case@collaborators
,@homepages
,@supportURLS
, etc. is ever used/supported directly in a metadata block... doubt it will based off of Anthony's prior responses for other keys but does make the code here simpler to read... and we don't need to be potentially overwriting user specified keys even if they don't really exist anywhere.Applies to:
@
keys #191@homepage
and upmix to@homepageURL
for symmetry #174@supportURL
is a pseudo unique key (e.g. non-upmixed) in our context as per the implied concern, especially at #96 (comment), around that issue. Authors can of course specify more at any time in their source but we only display/recognize the last one like GM standards for conflict resolution keys (and Scriptish probably already does for this exact key). I don't know of anyone yet that would want to have to check multiple places for issues. We could, at a future date, alter our issue tracker linkage if a user doesn't specify us as the primary. Some thoughts to ponder on... but that's another pr/issue down the line perhaps.Tested on dev at this script using this metadata block: