Skip to content

Commit 08485d7

Browse files
authored
Merge pull request #4 from kaje11/rng_update
Fixed HTML templating bug & Image width issue
2 parents 3b4b2ff + 25d37e4 commit 08485d7

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

src/openxml.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ def xl(self, children):
580580
self._insert(e)
581581
return e
582582

583-
def picture(self, filename, name='', descr='', cap=627):
583+
def picture(self, filename, name='', descr='', cap=None):
584584
# ext, content_type, relationships
585585
ext = filename.split('.')[-1]
586586
if ext == 'jpg':
@@ -618,9 +618,8 @@ def picture(self, filename, name='', descr='', cap=627):
618618
im = Image.open(filename)
619619
x, y = im.size
620620
if cap != None:
621-
if x > cap:
622-
y = int(round(float(cap * y) / x))
623-
x = cap
621+
y = int(round(float(cap * y) / x))
622+
x = cap
624623
x = str(x * 9525)
625624
y = str(y * 9525)
626625
e = etree.fromstring('''

src/report.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ class ns:
7676
#__vulnparam_highlighting = True
7777
#__truncate = True
7878
_pPr_annotation = False
79-
chartIterator = 0
8079

8180
def __init__(self):
8281
self._meta_init()
@@ -872,20 +871,18 @@ def _xml_apply_chart(self, chart_struct, values):
872871
chart_rid = chart.attrib['{%s}id' % self.ns.r]
873872

874873
# iterator used for identifying copies of charts
875-
self.chartIterator += 1
876-
chartNewId = chart_rid + 'copy' + str(self.chartIterator)
877-
878-
chart.attrib['{%s}id' % self.ns.r] = chartNewId
874+
newId = self._openxml.new_rel_id()
875+
chart.attrib['{%s}id' % self.ns.r] = "rId" + str(newId)
879876

880877
# charts/chart.xml
881878
chart_rel = filter(lambda x: x.attrib['Id'] == chart_rid and x.attrib[
882879
'Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart',
883880
etree.ETXPath('//{%s}Relationship' % self.ns.a)(self._xml))[0]
884881

885882
chart_rel_target = chart_rel.attrib['Target']
886-
chart_rel_targetCopy = 'copy' + str(self.chartIterator) + chart_rel_target
883+
chart_rel_targetCopy = 'copy' + str(newId) + chart_rel_target
887884
chart_relCopy = copy.deepcopy(chart_rel)
888-
chart_relCopy.attrib['Id'] = chartNewId
885+
chart_relCopy.attrib['Id'] = "rId" + str(newId)
889886
chart_relCopy.attrib['Target'] = chart_rel_targetCopy
890887
chart_relParent = chart_rel.getparent()
891888
chart_relParent.append(chart_relCopy)
@@ -918,7 +915,7 @@ def _xml_apply_chart(self, chart_struct, values):
918915
def copyRelPackages(relationship):
919916
# the original drawing name used for the chart
920917
relationshipName = relationship.attrib["Target"]
921-
relationshipCopyName = relationshipName.replace("../", "../copy" + str(self.chartIterator))
918+
relationshipCopyName = relationshipName.replace("../", "../copy" + str(newId))
922919
relationship.attrib["Target"] = relationshipCopyName
923920

924921
pkgName = relationshipName.replace("../", "/word/")

src/version.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,16 @@ class Version(object):
3131
Generate reports based on HP WebInspect, BurpSuite Pro scans,
3232
own custom data, knowledge base and Microsoft Office Word templates.
3333
'''
34-
version = '1.0.3'
35-
date = 'Tuesday Jan 12 11:00:00 2021'
34+
version = '1.0.5'
35+
date = 'Wed Jan 20 13:38:46 2021'
3636
changelog = '''
3737
''' + version + ''' - ''' + date + '''
38+
- Fixed images not resizing for width exceeding the inital size
39+
40+
1.0.4 - Tue Jan 19 20:42:36 2021
41+
- Fixed HTML support
42+
43+
1.0.3 - Tuesday Jan 12 11:00:00 2021
3844
- Nmap scan support for multiple XML files - gets enabled if 'OpenPorts' directive is found in the template
3945
- FIX: Fixed deprecated functions e.g. icon/OnFileDrop handling
4046
- Added support for multiple charts in the _xml_apply_chart functions via objects cloning

0 commit comments

Comments
 (0)