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

Diff doesn't render if there are unescaped characters in the config #70

Closed
notscottsmith opened this issue Jun 12, 2024 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@notscottsmith
Copy link

NetBox version
v3.7.8

Describe the bug
If the config which is rendered into the JS var jsonDiff has unescaped characters, the django filter "safe" doesn't pick them up.

Fix
Changing it to escapejs seems to fix it for me but I've not done extensive testing.

@notscottsmith notscottsmith added the bug Something isn't working label Jun 12, 2024
@miaow2
Copy link
Owner

miaow2 commented Jun 12, 2024

Hi @notscottsmith, please, provide an example of the diff, that does not render

@notscottsmith
Copy link
Author

Here's an excerpt of the config which would likely be causing an issue:

-radius-server template UFAAS-RADIUS-TEMPLATE
-radius-server shared-key cipher %^%#bK5vCFIF:Y0Uk1,2"fh"<W!dLL#fDP`XNl@F84E>[EZx5UoC&S+<:zT*&kKYe&5i'c0:.L-O-=&3q.zU\NV\<7L*m=7Ewl~ue7/M%^%#
-radius-server authentication 172.16.20.16 1812 source ip-address 192.168.172.254 weight 80
-radius-server authentication 172.16.30.6 1812 source ip-address 192.168.172.254 weight 40
-radius-server accounting 172.16.20.16 1813 source ip-address 192.168.172.254 weight 80
-radius-server accounting 172.16.30.6 1813 source ip-address 192.168.172.254 weight 40
-radius-server retransmit 4 timeout 8
-radius-server dead-time 1
-radius-attribute nas-ip 192.168.172.254
-radius-server algorithm loading-share

The cipher that gets created in the config has backticks in it as well as other characters which aren't being escaped by using "safe".

e.g. focusing on the cipher line:
radius-server shared-key cipher %^%#bK5vCFIF:Y0Uk1,2"fh"<W!dLL#fDP`XNl@F84E>[EZx5UoC&S+<:zT*&kKYe&5i'c0:.L-O-

That's how the text looks when it's using "safe", which will cause problems straight away.

Whereas when using escapejs, the same line looks like this:
radius\u002Dserver shared\u002Dkey cipher %^%#bK5vCFIF:Y0Uk1,2\u0022fh\u0022\u003CW!dLL#fDP\u0060XNl@F84E\u003E[EZx5UoC\u0026S+\u003C:zT*\u0026kKYe\u00265i\u0027c0:.L\u002DO\u002D\u003D\u00263q.zU\u005CNV\u005C\u003C7L*m\u003D7Ewl~ue7/M%^%#

Which allows it to be rendered in JS without problems.

@miaow2 miaow2 closed this as completed in b52db25 Jun 30, 2024
miaow2 added a commit that referenced this issue Jun 30, 2024
* Closes #67: Add option default_desired_privilege_level (#68)

* Closes #69: Fix logger in SecretsMixin (#71)

* Closes #70: Add escapejs filter to diff template (#72)

Co-authored-by: Clemens Knost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants