representation

What does Canonical Representation mean and its potential vulnerability to websites

时光毁灭记忆、已成空白 提交于 2019-12-01 15:54:00
I searched on google for a meaning of canonical representation and turned up documents that are entirely too cryptic. Can anyone provide a quick explanation of canonical representation and also what are some typical vulnerabilities in websites to canonical representation attacks? Canonicalisation is the process by which you take an input, such as a file name, or a string, and turn it into a standard representation. For example if your web application only allows access to files under C:\websites\mydomain then typically any input referring to filenames is canonicalised to be a physical, direct

What does Canonical Representation mean and its potential vulnerability to websites

余生颓废 提交于 2019-12-01 14:50:48
问题 I searched on google for a meaning of canonical representation and turned up documents that are entirely too cryptic. Can anyone provide a quick explanation of canonical representation and also what are some typical vulnerabilities in websites to canonical representation attacks? 回答1: Canonicalisation is the process by which you take an input, such as a file name, or a string, and turn it into a standard representation. For example if your web application only allows access to files under C:

Why are some Python strings are printed with quotes and some are printed without quotes?

时光毁灭记忆、已成空白 提交于 2019-11-30 20:11:30
I have a problem with string representations. I am trying to print my object and I sometimes get single quotes in the output. Please help me to understand why it happens and how can I print out the object without quotes. Here is my code: class Tree: def __init__(self, value, *children): self.value = value self.children = list(children) self.marker = "" def __repr__(self): if len(self.children) == 0: return '%s' %self.value else: childrenStr = ' '.join(map(repr, self.children)) return '(%s %s)' % (self.value, childrenStr) Here is what I do: from Tree import Tree t = Tree('X', Tree('Y','y'),

representation format in web2py database

╄→尐↘猪︶ㄣ 提交于 2019-11-30 13:43:58
db.define_table('person', Field('name'), format='%(name)s') What does this format do here? The format argument is used to determine how fields in other tables that reference the 'person' table will be displayed. For example, if you define: db.define_table('dog', Field('name'), Field('owner', db.person) The 'owner' field is a reference field that references the 'person' table (i.e., it stores record id's of records from the 'person' table). In most cases, when you display data from the 'dog' table, you don't want to display the raw db.person record id that is stored in the 'owner' field because

Why are some Python strings are printed with quotes and some are printed without quotes?

大城市里の小女人 提交于 2019-11-30 04:13:09
问题 I have a problem with string representations. I am trying to print my object and I sometimes get single quotes in the output. Please help me to understand why it happens and how can I print out the object without quotes. Here is my code: class Tree: def __init__(self, value, *children): self.value = value self.children = list(children) self.marker = "" def __repr__(self): if len(self.children) == 0: return '%s' %self.value else: childrenStr = ' '.join(map(repr, self.children)) return '(%s %s)

Fixed point vs Floating point number

。_饼干妹妹 提交于 2019-11-29 18:40:54
I just can't understand fixed point and floating point numbers due to hard to read definitions about them all over Google. But none that I have read provide a simple enough explanation of what they really are. Can I get a plain definition with example? Gabe A fixed point number has a specific number of bits (or digits) reserved for the integer part (the part to the left of the decimal point) and a specific number of bits reserved for the fractional part (the part to the right of the decimal point). No matter how large or small your number is, it will always use the same number of bits for each

two's complement

只谈情不闲聊 提交于 2019-11-29 17:09:42
As far as I know, the two's complement algo is: 1.Represent the decimal in binary. 2.Inverse all bits. 3.Add 1 to the last bit. For the number 3 , which its representation is: 0000000000000011 the result of the two's complement would be 1111111111111101 which is -3 . So far so good. But for the number 2 which its representation is 0000000000000010 the result of the two's complement would be 1111111111111101 , which isn't 2 but -3. What am I doing wrong? 0...0010 // 2 1...1101 // Flip the bits 1...1110 // Add one It works for negative too: 1...1110 // -2 0...0001 // Flip the bits 0...0010 //

How does the mechanism behind the creation of boxed traits work?

这一生的挚爱 提交于 2019-11-29 10:57:49
I'm having trouble understanding how values of boxed traits come into existence. Consider the following code: trait Fooer { fn foo(&self); } impl Fooer for i32 { fn foo(&self) { println!("Fooer on i32!"); } } fn main() { let a = Box::new(32); // works, creates a Box<i32> let b = Box::<i32>::new(32); // works, creates a Box<i32> let c = Box::<Fooer>::new(32); // doesn't work let d: Box<Fooer> = Box::new(32); // works, creates a Box<Fooer> let e: Box<Fooer> = Box::<i32>::new(32); // works, creates a Box<Fooer> } Obviously, variant a and b work, trivially. However, variant c does not, probably

When and how is conversion to char pointer allowed?

泪湿孤枕 提交于 2019-11-28 20:28:15
We can look at the representation of an object of type T by converting a T* that points at that object into a char* . At least in practice: int x = 511; unsigned char* cp = (unsigned char*)&x; std::cout << std::hex << std::setfill('0'); for (int i = 0; i < sizeof(int); i++) { std::cout << std::setw(2) << (int)cp[i] << ' '; } This outputs the representation of 511 on my system: ff 01 00 00 . There is (surely) some implementation defined behaviour occurring here. Which of the casts is allowing me to convert an int* to an unsigned char* and which conversions does that cast entail? Am I invoking

Fixed point vs Floating point number

假如想象 提交于 2019-11-28 13:25:02
问题 I just can't understand fixed point and floating point numbers due to hard to read definitions about them all over Google. But none that I have read provide a simple enough explanation of what they really are. Can I get a plain definition with example? 回答1: A fixed point number has a specific number of bits (or digits) reserved for the integer part (the part to the left of the decimal point) and a specific number of bits reserved for the fractional part (the part to the right of the decimal