8 kyu
Safen User Input Part I - htmlspecialchars
4,973 of 9,423donaldsebleung
Loading description...
Fundamentals
Strings
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Scala sample tests error out:
Cannot fix, when I paste the correct tests into the sample tests box and save them they revert to the state on live.
I managed to get it to go through by publishing without saving first, so fixed.
It was only affecting the sample tests box as well.
Note for anyone touching this in Scala in the future: forking will break the sample tests.
Scala translation
Approved
See the issue above.
Cannot complete sample test cases in Python. Strings are the same, but does not equal to each other
Site or test issue?
Diff -> &qout "
Strings aren't same
@Matti762, thanks a lot!
RISC-V: syntax errors and incorrect expected values in the sample tests.
This is weird - it seems that Codewars misrecognized my
#include
s as unmatched HTML tags and tried to auto-correct them.I'll publish and approve a revised RISC-V translation to fix it. If the issue still persists or resurfaces, it might be a site issue.
Yep, can confirm it's a site bug that affects the sample tests on every save before publishing the translation. Just double-checked to confirm it (the RISC-V translation, not the site issue) is fixed now.
Actually, I think it may have something to do with filtering content that includes
<script>
. I vaguely remember a similar confusing issue that I didn't fully understand.This kata is a subject to deduplication process here: https://github.com/codewars/content-issues/issues/137.
Please join the discussion to help us identify duplicate kata and retire them.
This kata was decided to stay.
Delete this
This comment has been hidden.
That method requires Node 15+, which is not currently available in CW.
python: html tags shouldn't be used inside messages of
it/describe
blocks. This leads to wrong/unusual display in the output consoleYup, that looks like pretty unusual and odd, in contrary to the common text (especially with the regular-sized
Random tests
).Anyways, I've made a translation which should fix this issue: https://www.codewars.com/kumite/636b97b7151bc40064840e7e?sel=636b97b7151bc40064840e7e. Please check and approve :)
thx
Ruby translation kumited -- please check and approve
Approved. Sample tests always pass so I've fixed it in editor
This comment has been hidden.
The tests for python are super broken. My solution passes the sample tests and then fails the exact same tests when they occur in the larger set of test cases
My solution passes the test cases needed but not the sample test cases. I can complete the kata but cannot pass the sample test cases. The sample test cases are wrong.
fixed
This comment has been hidden.
The sample tests in Python are incorrect.
fixed
fixed by myself ~~
Python translation
Approved ~~
I am working in a python translation but i'm having problems with the expected results.
changes to
every time I save the translation.
Any clues?
Probably there is a bug in "sample test cases" editor (full tests don't change on save).
An idea (I dont know if it works): save the translation, paste sample tests from ide, and publish without saving.
Done. Thanks
fun easy kata; this issue ^ might be back tho, @albertogcmr
No test cases
Duplicate issue and there are no fixed tests, not tests.
A kata would be worthless without tests.
See @cliffstamp's issue below :point_down:
(duplicate)
This comment has been hidden.
JS :
Especially important for beginner kata.
fixed
I suggest a test to add. Motivation: if an HTML input string already contains "&", you don't want to transform it into "&"; describe("Solution", function(){ it("@amp;", function(){ Test.assertEquals(htmlspecialchars("&"), "&", "the & in the already correct substrings should not change"); }); });
JavaScript has no sample tests.
It leaves me pondering my existence when I look at the example template.
Edit: Also if randNumGen watches the Math.random, then who watches the randNumGen?
Thanks for your feedback :) This Kata was authored when I was still relatively new to Codewars so please forgive me if it is not of top quality. Since you mentioned it, I may revisit this Kata in my spare time and completely rework the test cases if possible. Cheers :)
fixed
"<h2>Hello World</h2>", instead got: "<h2>Hello World</h2>" output is '<h2>Hello World</h2>'
I always use
xmp
tag to see the real output. I.e.console.log('<xmp>'+formData+'</xmp>');
tried this xmp
so output is '<h2>Hello World</h2>'
maybe i missing something in description? dont know why test not validates it...
@maliknur I think your HTML special characters need to end with a semicolon e.g.
<
instead of just<
.Semicolon did the trick for me, too. I missed it in the instructions. (I guess I'm so accustomed to seeing JavaScript lines end with semicolons, I've learned to ignore them :)
This comment has been hidden.
The order of substitution is incorrect which may result in double encoding. Hope this helps :)
Yep, that was it. Thank you.
CofeeScript Translation Kumited! please accept :D
Approved :)
TY! :D
Can you please review your tests I got
my bad it seems :$
You can try escaping html chars trough xmp tag in case you got something weird on your tests :)
Created TypeScript Translation
Approved :)
Needs random test cases!
Hi matt c guessed I would need random test cases but can you please teach me how to do this strings? I could easily generate random results with numbers but I'm a bit stuck as to how to do it with strings.
Thank you :D
Gladly ;)
As per your request, a random string test has been added.
Issue resolved.