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

new liquid tag - dotnetfiddle #10788

Merged
merged 4 commits into from Oct 16, 2020
Merged

Conversation

ShubhankarKG
Copy link
Contributor

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

This PR adds a new liquid tag, dotnetfiddle.

Related Tickets & Documents

Fixes #10402

Added tests?

  • yes
  • no, because they aren't needed
  • no, because I need help

Added to documentation?

  • docs.forem.com
  • readme
  • no documentation needed

PS : Apologies for the delay

@ShubhankarKG ShubhankarKG requested a review from a team October 12, 2020 04:07
@ShubhankarKG ShubhankarKG requested a review from a team as a code owner October 12, 2020 04:07
@pr-triage pr-triage bot added the PR: unreviewed bot applied label for PR's with no review label Oct 12, 2020
@CLAassistant
Copy link

CLAassistant commented Oct 12, 2020

CLA assistant check
All committers have signed the CLA.

@ShubhankarKG
Copy link
Contributor Author

Okay, I would like some help in the tests section 😅

@citizen428
Copy link
Contributor

@ShubhankarKG How can we help you with the tests? 😃

@ShubhankarKG
Copy link
Contributor Author

My approval test passed on 2 out of 3 builds and failed on 1. The approval test is causing a bit of a problem here. 😭

@citizen428
Copy link
Contributor

Thanks for clarifying, I'll have a look.

@citizen428
Copy link
Contributor

citizen428 commented Oct 12, 2020

The problem was that calling liquid.render on line 20 of the spec resulted in an error:

"Liquid error: internal"

So I started a development server and made a post including the Liquid tag {% dotnetfiddle https://dotnetfiddle.net/Widget/v2kx9jcd %} This also raises an exception and the provided link results in a 404.

I guess you should be able to further debug things from here.

Copy link
Contributor

@rhymes rhymes left a comment

Choose a reason for hiding this comment

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

Hi @ShubhankarKG, thanks for the PR. Left a note

Starting from https:// we end at 24 characters at dotnetfiddle.net %>

<iframe
src="<%= link.insert(24, "/Widget").to_s %>"
Copy link
Contributor

Choose a reason for hiding this comment

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

can we keep this "hack" in the liquit tag ruby file? We should also test it :D

Is there a chance the number of chars will change?

Copy link
Contributor

Choose a reason for hiding this comment

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

➕ for moving this into the actual tag instead of keeping it in the view. I think the 24 is unlikely to change, as it's the lenght of "https://dotnetfiddle.net", but I think a more robust solution with Ruby's URI module for building the link would be preferable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, thanks for the inputs everyone. I had the "hack" (xD) shifted in the controller, but I sticked to using the string.insert method.

I'll try to make the change through the URI module now. Thanks for the heads up :+1

2. Use URI to check if Widget keyword doesn't exist, then insert Widget using URI
2. Updated code to eliminate xss_attacks
Co-authored-by: Michael Kohl <me@citizen428.net>
@pr-triage pr-triage bot added PR: partially-approved bot applied label for PR's where a single reviewer approves changes and removed PR: unreviewed bot applied label for PR's with no review labels Oct 15, 2020
@benhalpern benhalpern merged commit a60c923 into forem:master Oct 16, 2020
@pr-triage pr-triage bot added PR: merged bot applied label for PR's that are merged and removed PR: partially-approved bot applied label for PR's where a single reviewer approves changes labels Oct 16, 2020
@ShubhankarKG ShubhankarKG deleted the dotnetfiddle branch October 17, 2020 07:13
boardfish pushed a commit to boardfish/forem that referenced this pull request Oct 17, 2020
* new liquid tag - dotnetfiddle

* 1. Moved the hack into controller
2. Use URI to check if Widget keyword doesn't exist, then insert Widget using URI

* 1. Fixed tests
2. Updated code to eliminate xss_attacks

* Update app/liquid_tags/dotnet_fiddle_tag.rb to match pr comment

Co-authored-by: Michael Kohl <me@citizen428.net>

Co-authored-by: Michael Kohl <me@citizen428.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: merged bot applied label for PR's that are merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for dotnetfiddle.net
5 participants