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

JS error in imagediff.js #19414

Closed
wxiaoguang opened this issue Apr 16, 2022 · 4 comments · Fixed by #19494
Closed

JS error in imagediff.js #19414

wxiaoguang opened this issue Apr 16, 2022 · 4 comments · Fixed by #19494
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented topic/ui Change the appearance of the Gitea UI type/bug
Milestone

Comments

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Apr 16, 2022

caught by #18971 (Show JS errors) , reported by a user.

caused by imagediff.js

function getDefaultSvgBoundsIfUndefined(svgXml, src) {
  const DefaultSize = 300;
  const MaxSize = 99999;

  const svg = svgXml.rootElement; // BUG, here svg might be null, then the following `svg.width` triggers JS error

  const width = svg.width.baseVal;
  const height = svg.height.baseVal;
  if (width.unitType === SVGLength.SVG_LENGTHTYPE_PERCENTAGE || height.unitType === SVGLength.SVG_LENGTHTYPE_PERCENTAGE) {

image

Compiled JS, the index.js:37:1821 is at c=o.width

o=e.rootElement,c=o.width.baseVal,y=o.height.baseVal;if(c.unitType===SVGLength.SVG_LENGTHTYPE_PERCENTAG
@wxiaoguang wxiaoguang added type/bug topic/ui Change the appearance of the Gitea UI issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented labels Apr 16, 2022
@wxiaoguang wxiaoguang added this to the 1.17.0 milestone Apr 16, 2022
@KN4CK3R
Copy link
Member

KN4CK3R commented Apr 17, 2022

Do you have an example svg?

@wxiaoguang
Copy link
Contributor Author

No, I have asked but the reporter can not provide more information.

@wxiaoguang
Copy link
Contributor Author

I managed to reproduce it. See https://try.gitea.io/wxiaoguang/test/pulls/6/files

@wxiaoguang
Copy link
Contributor Author

I proposed a fix #19494

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented topic/ui Change the appearance of the Gitea UI type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants